/** * Load or generate the menu configuration data. For the menu to function, the button actions must * be an 'utterance' or 'press' event - no other button actions will be responded to. * @callback jibo.bt.behaviors.Menu~GetConfig * @param {Function} callback When config has been loaded or generated, pass it to this callback. */ /** * Called when a Menu times out or closes. Return value finds an exception handler within the flow. *Unhandled exceptions use the default behavior of returning to Jibo's idle state. * @callback jibo.bt.behaviors.Menu~OnMenuClosed * @param {boolean} timedOut `true` if the menu timed out, `false` if it was closed by the user. * @param {jibo.face.views.MenuView} menu Created menu. Use to read menu position or any other information before the menu closes. * @param {Function} overrideMenuTransition Override the transition out of the menu. Pass a [ChangeOptions]{@link jibo.face.views~ChangeOptions} to control the transition, or `remain` in order to leave the menu in place. * @param {String} results.exception (Flow Only) Exception for the closed menu; either `~InteractionError.MenuTimeout` or `~InteractionError.MenuClosed`. */ /** * Called when an item has been chosen. * @callback jibo.bt.behaviors.Menu~OnItemChosen * @param {any} results Either the listen results or the button press event, depending on how the menu is configured. * @param {jibo.face.views.MenuView} menu Created menu. Use to read menu position or any other information before the menu closes. * @param {Function} overrideMenuTransition Call to override the transition out of the menu. Pass a [ChangeOptions]{@link jibo.face.views~ChangeOptions} to control the transition, or `remain` in order to leave the menu in place. */ /** * Called to confirm that a positional selection makes sense, allowing custom handling to select certain types of items, if desired. This is called when a user says something like 'open the one on the right', and is called before the onItemChosen callback. * @callback jibo.bt.behaviors.Menu~OnPositionalSelect * @param {jibo.mim.AsrResult} commandASR Data from NLU service. * @param {Number} intendedIndex Index that the menu plans to use for selection. * @param {jibo.face.views.MenuView} menu Created menu. Use to read button data, if you didn't keep track of it yourself. * @returns {number} An item index to change what will be selected, or NaN to select nothing. Returning undefined will use the default behavior (selecting intendedIndex). */ /** * @class Menu * @extends jibo.bt.Behavior * @memberof jibo.bt.behaviors * @description A single stage menu. * @param {Object} options See {@link jibo.bt.Behavior|Behavior} for all options. * @param {jibo.bt.behaviors.Menu~GetConfig} options.getConfig Load or generate the menu config data. * @param {jibo.bt.behaviors.Menu~OnMenuClosed} options.onMenuClosed Called if the menu times out or is closed. * @param {jibo.bt.behaviors.Menu~OnItemChosen} options.onItemChosen Called when the user picks an item from the list. * @param {jibo.bt.behaviors.Menu~OnPositionalSelect} options.onPositionalSelect Called when the user uses a positional selection voice command */ /** * Callback for button 'press' events from the menu. * @method jibo.bt.Menu#onPressEvent * @param {any} event Whatever the press event from the menu was, as defined in the view config. * @private */ /** * Callback for when the list is closed for any reason. * @method jibo.bt.Menu#onListClosed * @private */