- ButtonPopup ⇐
EventEmitter
- x :
number
The x offset of the popup to be drown. If 0 it will be placed on the center
- y :
number
The y offset of the popup to be drown. If 0 it will be placed on the center
- CM :
ConsoleManager
the instance of ConsoleManager (singleton)
- ButtonPopupConfig :
Object
The configuration for the ButtonPopup class.
The configuration for the ButtonPopup class.
Kind: global interface
Properties
Name | 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 ["Ok", "Cancel", "?"]). |
[visible] | boolean |
If the popup is visible. Default is false (make it appears using show()). |
Kind: global class
Extends: EventEmitter
- ButtonPopup ⇐
EventEmitter
This class is used to create a popup with That asks for a confirm.
Emits the following events:
- "confirm" when the user confirm
- "cancel" when the user cancel
- "exit" when the user exit
Param | Type | Description |
---|---|---|
config | ButtonPopupConfig |
The configuration of the popup. |
Example
const popup = new ButtonPopup({
id: "popup1",
title: "Choose the option",
buttons: ["YES", "NO", "?"],
})
popup.show() // show the popup
popup.on("confirm", () => {
console.log("User confirmed")
})
popup.on("cancel", () => {
console.log("User canceled")
})
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.
Kind: instance method of ButtonPopup
Param | Type | Description |
---|---|---|
_str | string |
The string of the input. |
key | any |
The key object. |
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.
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.
The x offset of the popup to be drown. If 0 it will be placed on the center
The y offset of the popup to be drown. If 0 it will be placed on the center
the instance of ConsoleManager (singleton)
Kind: global constant