- CustomPopup ⇐
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)
- PopupConfig :
Object
The configuration for the CustomPopup class.
The configuration for the CustomPopup class.
Kind: global interface
Properties
Name | Type | Description |
---|---|---|
id | string |
The id of the popup. |
title | string |
The title of the popup. |
content | PageBuilder |
The content of the popup. |
width | number |
The width of the popup. |
[visible] | boolean |
If the popup is visible. |
Kind: global class
Extends: EventEmitter
- CustomPopup ⇐
EventEmitter
- new CustomPopup(config)
- .keyListener(str, key)
- .getContent() ⇒
PageBuilder
- .setContent(newContent) ⇒
CustomPopup
- .setWidth(newWidth) ⇒
CustomPopup
- .show() ⇒
CustomPopup
- .hide() ⇒
CustomPopup
- .isVisible() ⇒
boolean
- .manageInput() ⇒
CustomPopup
- .unManageInput() ⇒
CustomPopup
- .drawLine(line) ⇒
void
- .draw() ⇒
CustomPopup
This class is used to create a popup with a free content built with PageBuilder class.
Emits the following events:
- "confirm" when the user confirm
- "cancel" when the user cancel
- "exit" when the user exit
- "data" when the user send custom event - the data is an object with the data and the event name
Param | Type | Description |
---|---|---|
config | PopupConfig |
The configuration of the popup. |
Example
const popup = new CustomPopup({
id: "popup1",
title: "See that values",
content: new PageBuilder().addText("Hello world!"),
}).show()
<a name="CustomPopup+keyListener"></a>
### customPopup.keyListener(str, key)
<p>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.</p>
**Kind**: instance method of [<code>CustomPopup</code>](#CustomPopup)
| Param | Type | Description |
| --- | --- | --- |
| str | <code>string</code> | <p>The string of the input.</p> |
| key | <code>Object</code> | <p>The key object.</p> |
<a name="CustomPopup+getContent"></a>
### customPopup.getContent() ⇒ <code>PageBuilder</code>
<p>This function is used to get the content of the popup.</p>
**Kind**: instance method of [<code>CustomPopup</code>](#CustomPopup)
**Returns**: <code>PageBuilder</code> - <p>The content of the popup.</p>
<a name="CustomPopup+setContent"></a>
### customPopup.setContent(newContent) ⇒ [<code>CustomPopup</code>](#CustomPopup)
<p>This function is used to change the content of the popup. It also refresh the ConsoleManager.</p>
**Kind**: instance method of [<code>CustomPopup</code>](#CustomPopup)
**Returns**: [<code>CustomPopup</code>](#CustomPopup) - <p>The instance of the CustomPopup.</p>
| Param | Type | Description |
| --- | --- | --- |
| newContent | <code>PageBuilder</code> | <p>The new content of the popup.</p> |
<a name="CustomPopup+setWidth"></a>
### customPopup.setWidth(newWidth) ⇒ [<code>CustomPopup</code>](#CustomPopup)
<p>This function is used to change the popup width. It also refresh the ConsoleManager.</p>
**Kind**: instance method of [<code>CustomPopup</code>](#CustomPopup)
**Returns**: [<code>CustomPopup</code>](#CustomPopup) - <p>The instance of the CustomPopup.</p>
| Param | Type | Description |
| --- | --- | --- |
| newWidth | <code>number</code> | <p>The new width of the popup.</p> |
<a name="CustomPopup+show"></a>
### customPopup.show() ⇒ [<code>CustomPopup</code>](#CustomPopup)
<p>This function is used to show the popup. It also register the key events and refresh the ConsoleManager.</p>
**Kind**: instance method of [<code>CustomPopup</code>](#CustomPopup)
**Returns**: [<code>CustomPopup</code>](#CustomPopup) - <p>The instance of the CustomPopup.</p>
<a name="CustomPopup+hide"></a>
### customPopup.hide() ⇒ [<code>CustomPopup</code>](#CustomPopup)
<p>This function is used to hide the popup. It also unregister the key events and refresh the ConsoleManager.</p>
**Kind**: instance method of [<code>CustomPopup</code>](#CustomPopup)
**Returns**: [<code>CustomPopup</code>](#CustomPopup) - <p>The instance of the CustomPopup.</p>
<a name="CustomPopup+isVisible"></a>
### customPopup.isVisible() ⇒ <code>boolean</code>
<p>This function is used to get the visibility of the popup.</p>
**Kind**: instance method of [<code>CustomPopup</code>](#CustomPopup)
**Returns**: <code>boolean</code> - <p>The visibility of the popup.</p>
<a name="CustomPopup+manageInput"></a>
### customPopup.manageInput() ⇒ [<code>CustomPopup</code>](#CustomPopup)
<p>This function is used to add the CustomPopup key listener callback to te ConsoleManager.</p>
**Kind**: instance method of [<code>CustomPopup</code>](#CustomPopup)
**Returns**: [<code>CustomPopup</code>](#CustomPopup) - <p>The instance of the CustomPopup.</p>
<a name="CustomPopup+unManageInput"></a>
### customPopup.unManageInput() ⇒ [<code>CustomPopup</code>](#CustomPopup)
<p>This function is used to remove the CustomPopup key listener callback to te ConsoleManager.</p>
**Kind**: instance method of [<code>CustomPopup</code>](#CustomPopup)
**Returns**: [<code>CustomPopup</code>](#CustomPopup) - <p>The instance of the CustomPopup.</p>
<a name="CustomPopup+drawLine"></a>
### customPopup.drawLine(line) ⇒ <code>void</code>
<p>This function is used to draw a single line of the layout to the screen. It also trim the line if it is too long.</p>
**Kind**: instance method of [<code>CustomPopup</code>](#CustomPopup)
| Param | Type | Description |
| --- | --- | --- |
| line | <code>Array.<object></code> | <p>the line to be drawn</p> |
<a name="CustomPopup+draw"></a>
### customPopup.draw() ⇒ [<code>CustomPopup</code>](#CustomPopup)
<p>This function is used to draw the CustomPopup to the screen in the middle.</p>
**Kind**: instance method of [<code>CustomPopup</code>](#CustomPopup)
**Returns**: [<code>CustomPopup</code>](#CustomPopup) - <p>The instance of the CustomPopup.</p>
<a name="x"></a>
## x : <code>number</code>
<p>The x offset of the popup to be drown. If 0 it will be placed on the center</p>
**Kind**: global variable
<a name="y"></a>
## y : <code>number</code>
<p>The y offset of the popup to be drown. If 0 it will be placed on the center</p>
**Kind**: global variable
<a name="CM"></a>
## CM : <code>ConsoleManager</code>
<p>the instance of ConsoleManager (singleton)</p>
**Kind**: global constant