1.1.7
What's Changed
- Add PageDown and PageUp function in scrollable OptionPopup by @Elius94 in #18
- Add new widget: Confirm Popup (Yes, no) by @Elius94 in #19
Full Changelog: 1.1.6...1.1.7
Added two Widgets
ButtonPopup
Classes
- ButtonPopup ⇐
EventEmitter
Constants
- CM :
ConsoleManager
the instance of ConsoleManager (singleton)
Functions
- key)(str, key)
This function is used to make the ConsoleManager handle the key events when the popup is showed. Inside this function are defined all the keys that can be pressed and the actions to do when they are pressed.
ButtonPopup ⇐ EventEmitter
Kind: global class
Extends: EventEmitter
- ButtonPopup ⇐
EventEmitter
new ButtonPopup(id, title, message, buttons, visible)
- "exit" when the user exitncelrmpup with That asks for a confirm.
Param | Type | Description |
---|---|---|
id | string |
The id of the popup. |
title | string |
The title of the popup. |
message | string |
The message of the popup. |
buttons | Array.<string> |
The buttons of the popup (default is ["Yes", "No"]). |
visible | boolean |
If the popup is visible. Default is false (make it appears using show()). |
Example
const popup = new ButtonPopup("popup1", "Choose the option", ["YES", "NO", "?"]).show().on("confirm", (answer) => { console.log(answer) }) // show the popup and wait for the user to confirm
buttonPopup.show() ⇒ ButtonPopup
This function is used to show the popup. It also register the key events and refresh the ConsoleManager.
Kind: instance method of ButtonPopup
Returns: ButtonPopup
- The instance of the ButtonPopup.
buttonPopup.hide() ⇒ ButtonPopup
This function is used to hide the popup. It also unregister the key events and refresh the ConsoleManager.
Kind: instance method of ButtonPopup
Returns: ButtonPopup
- The instance of the ButtonPopup.
buttonPopup.isVisible() ⇒ boolean
This function is used to get the visibility of the popup.
Kind: instance method of ButtonPopup
Returns: boolean
- The visibility of the popup.
buttonPopup.manageInput() ⇒ ButtonPopup
This function is used to add the ButtonPopup key listener callback to te ConsoleManager.
Kind: instance method of ButtonPopup
Returns: ButtonPopup
- The instance of the ButtonPopup.
buttonPopup.unManageInput() ⇒ ButtonPopup
This function is used to remove the ButtonPopup key listener callback to te ConsoleManager.
Kind: instance method of ButtonPopup
Returns: ButtonPopup
- The instance of the ButtonPopup.
buttonPopup.draw() ⇒ ButtonPopup
This function is used to draw the ButtonPopup to the screen in the middle.
Kind: instance method of ButtonPopup
Returns: ButtonPopup
- The instance of the ButtonPopup.
CM : ConsoleManager
the instance of ConsoleManager (singleton)
Kind: global constant
ConfirmPopup
ConfirmPopup ⇐ ButtonPopup
Kind: global class
Extends: ButtonPopup
new ConfirmPopup(id, title, message, visible)
This class is an overload of ButtonPopup that is used to create a popup wi- "exit" when the user exitncelrmNo].
Param | Type | Description |
---|---|---|
id | string |
The id of the popup. |
title | string |
The title of the popup. |
message | string |
The message of the popup. |
visible | boolean |
If the popup is visible. Default is false (make it appears using show()). |
Example
const popup = new ConfirmPopup("popup1", "Are you shure").show().on("confirm", (answer) => { console.log(answer) }) // show the popup and wait for the user to confirm