- InputPopup ⇐
EventEmitter
- cursorPos :
number
Since v3.1.0 a blinking cursor has been added to InputPopup (thanks @Compositr)
- flashLoop :
setInterval
Since v3.1.0 a blinking cursor has been added to InputPopup (thanks @Compositr)
- 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)
- InputPopupConfig :
Object
The configuration for the InputPopup class.
The configuration for the InputPopup class.
Kind: global interface
Properties
Name | Type | Description |
---|---|---|
id | string |
The id of the popup. |
title | string |
The title of the popup. |
value | string | number |
The value of the popup. |
numeric | boolean |
If the input is numeric. |
[visible] | boolean |
If the popup is visible. |
[placeholder] | string |
Optional placeholder to show if empty |
[maxLen] | number |
Optional max length of the input (default 20). Set to 0 for no limit (not recommended). Since v3.4.0 |
Kind: global class
Extends: EventEmitter
- InputPopup ⇐
EventEmitter
This class is used to create a popup with a text or numeric input.
Emits the following events:
- "confirm" when the user confirm the input
- "cancel" when the user cancel the input
- "exit" when the user exit the input
Param | Type | Description |
---|---|---|
config | InputPopupConfig |
The config of the popup. |
Example
const popup = new InputPopup({
id: "popup1",
title: "Choose the number",
value: selectedNumber,
numeric: true
}).show().on("confirm", (value) => { console.log(value) }) // show the popup and wait for the user to confirm
This function is used to make the ConsoleManager handle the key events when the input is numeric and it 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 InputPopup
Param | Type | Description |
---|---|---|
_str | string |
The string of the input. |
key | Object |
The key object. |
This function is used to make the ConsoleManager handle the key events when the input is text and it 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 InputPopup
Param | Type | Description |
---|---|---|
_str | string |
The string of the input. |
key | Object |
The key object. |
This function is used to get the value of the input.
Kind: instance method of InputPopup
Returns: string
| number
-
The value of the input.
inputPopup.setValue(newValue) ⇒ InputPopup
This function is used to change the value of the input. It also refresh the ConsoleManager.
Kind: instance method of InputPopup
Returns: InputPopup
-
The instance of the InputPopup.
Param | Type | Description |
---|---|---|
newValue | string | number |
The new value of the input. |
inputPopup.show() ⇒ InputPopup
This function is used to show the popup. It also register the key events and refresh the ConsoleManager.
Kind: instance method of InputPopup
Returns: InputPopup
-
The instance of the InputPopup.
inputPopup.hide() ⇒ InputPopup
This function is used to hide the popup. It also unregister the key events and refresh the ConsoleManager.
Kind: instance method of InputPopup
Returns: InputPopup
-
The instance of the InputPopup.
This function is used to get the visibility of the popup.
Kind: instance method of InputPopup
Returns: boolean
-
The visibility of the popup.
inputPopup.manageInput() ⇒ InputPopup
This function is used to add the InputPopup key listener callback to te ConsoleManager.
Kind: instance method of InputPopup
Returns: InputPopup
-
The instance of the InputPopup.
inputPopup.unManageInput() ⇒ InputPopup
This function is used to remove the InputPopup key listener callback to te ConsoleManager.
Kind: instance method of InputPopup
Returns: InputPopup
-
The instance of the InputPopup.
inputPopup.draw() ⇒ InputPopup
This function is used to draw the InputPopup to the screen in the middle.
Kind: instance method of InputPopup
Returns: InputPopup
-
The instance of the InputPopup.
Since v3.1.0 a blinking cursor has been added to InputPopup (thanks @Compositr)
Since v3.1.0 a blinking cursor has been added to InputPopup (thanks @Compositr)
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