Skip to content

Latest commit

 

History

History
206 lines (151 loc) · 8.09 KB

CustomPopup.md

File metadata and controls

206 lines (151 loc) · 8.09 KB

Classes

CustomPopupEventEmitter

Members

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

Constants

CM : ConsoleManager

the instance of ConsoleManager (singleton)

Interfaces

PopupConfig : Object

The configuration for the CustomPopup class.

PopupConfig : Object

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.

CustomPopup ⇐ EventEmitter

Kind: global class
Extends: EventEmitter

new CustomPopup(config)

This class is used to create a popup with a free content built with PageBuilder class.

Animation

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.&lt;object&gt;</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