Skip to content

Latest commit

 

History

History
167 lines (126 loc) · 6.19 KB

ButtonPopup.md

File metadata and controls

167 lines (126 loc) · 6.19 KB

Classes

ButtonPopupEventEmitter

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

ButtonPopupConfig : Object

The configuration for the ButtonPopup class.

ButtonPopupConfig : Object

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()).

ButtonPopup ⇐ EventEmitter

Kind: global class
Extends: EventEmitter

new ButtonPopup(config)

This class is used to create a popup with That asks for a confirm.

ButtonPopup

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")
})

buttonPopup.keyListener(_str, key)

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.


buttonPopup.isVisible() ⇒ boolean

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.


x : number

The x offset of the popup to be drown. If 0 it will be placed on the center

Kind: global variable

y : number

The y offset of the popup to be drown. If 0 it will be placed on the center

Kind: global variable

CM : ConsoleManager

the instance of ConsoleManager (singleton)

Kind: global constant