const p = new PageBuilder(5) // Add a scroll limit so it will be scrollable with up and down
p.addRow({ text: `Example of a custom popup content!`, color: 'yellow' })
p.addRow({ text: `This is a custom popup!`, color: 'green' })
p.addRow({ text: `It can be used to show a message,`, color: 'green' })
p.addRow({ text: `or to show variables.`, color: 'green' })
p.addRow({ text: `TCP Message sent: `, color: 'green' }, { text: `${tcpCounter}`, color: 'white' })
p.addRow({ text: `Connected clients: `, color: 'green' }, { text: `${connectedClients}`, color: 'white' })
p.addRow({ text: `Mode: `, color: 'green' }, { text: `${mode}`, color: 'white' })
p.addRow({ text: `Message period: `, color: 'green' }, { text: `${period} ms`, color: 'white' })
new CustomPopup("popupCustom1", "See that values", p, 32).show()
Description
Draws a popup that allows to pass a PageBuilder class to be drawed
inside it.
new CustomPopup(id, title, content, width, visible)
This class is used to create a popup with a free content built- "data" when the user send custom event - the data is an object with the data and the event name
Param
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. Default is false (make it appears using show()).
Example
const popup = new CustomPopup("popup1", "Choose the number", selectedNumber, true).show().on("confirm", (value) => { console.log(value) }) // show the popup and wait for the user to confirm
customPopup.keyListner(str, key)
This function is used to make the ConsoleManager handle the keInside this function are defined all the keys that can be pressed and the actions to do when they are pressed.
New widget: Free content popup Fixes #21
Added new widget: CustomPopup
See the example using
and press "1"
Usage
Description
Draws a popup that allows to pass a PageBuilder class to be drawed inside it.
Docs
Classes
EventEmitter
Constants
ConsoleManager
the instance of ConsoleManager (singleton)
CustomPopup ⇐
EventEmitter
Kind: global class
Extends:
EventEmitter
EventEmitter
PageBuilder
CustomPopup
CustomPopup
CustomPopup
CustomPopup
boolean
CustomPopup
CustomPopup
void
CustomPopup
new CustomPopup(id, title, content, width, visible)
This class is used to create a popup with a free content built- "data" when the user send custom event - the data is an object with the data and the event name
string
string
PageBuilder
number
boolean
Example
customPopup.keyListner(str, key)
This function is used to make the ConsoleManager handle the keInside this function are defined all the keys that can be pressed and the actions to do when they are pressed.
Kind: instance method of
CustomPopup
string
Object
customPopup.getContent() ⇒
PageBuilder
This function is used to get the content of the popup.
Kind: instance method of
CustomPopup
Returns:PageBuilder
- The content of the popup.customPopup.setContent(newContent) ⇒
CustomPopup
This function is used to change the content of the popup. It also refresh the ConsoleManager.
Kind: instance method of
CustomPopup
Returns:CustomPopup
- The instance of the CustomPopup.PageBuilder
customPopup.setWidth(newWidth) ⇒
CustomPopup
This function is used to change the popup width. It also refresh the ConsoleManager.
Kind: instance method of
CustomPopup
Returns:CustomPopup
- The instance of the CustomPopup.number
customPopup.show() ⇒
CustomPopup
This function is used to show the popup. It also register the key events and refresh the ConsoleManager.
Kind: instance method of
CustomPopup
Returns:CustomPopup
- The instance of the CustomPopup.customPopup.hide() ⇒
CustomPopup
This function is used to hide the popup. It also unregister the key events and refresh the ConsoleManager.
Kind: instance method of
CustomPopup
Returns:CustomPopup
- The instance of the CustomPopup.customPopup.isVisible() ⇒
boolean
This function is used to get the visibility of the popup.
Kind: instance method of
CustomPopup
Returns:boolean
- The visibility of the popup.customPopup.manageInput() ⇒
CustomPopup
This function is used to add the CustomPopup key listener callback to te ConsoleManager.
Kind: instance method of
CustomPopup
Returns:CustomPopup
- The instance of the CustomPopup.customPopup.unManageInput() ⇒
CustomPopup
This function is used to remove the CustomPopup key listener callback to te ConsoleManager.
Kind: instance method of
CustomPopup
Returns:CustomPopup
- The instance of the CustomPopup.customPopup.drawLine(line) ⇒
void
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.
Kind: instance method of
CustomPopup
Array.<object>
customPopup.draw() ⇒
CustomPopup
This function is used to draw the CustomPopup to the screen in the middle.
Kind: instance method of
CustomPopup
Returns:CustomPopup
- The instance of the CustomPopup.CM :
ConsoleManager
the instance of ConsoleManager (singleton)
Kind: global constant