Class: WindowChoices

WindowChoices

A class for window choices

new WindowChoices (x, y, w, h, listContents, opts)

Name Type Default Description
x number The x coords
y number The y coords
w number The w coords
h number The h coords
listContents Array.<Object> List of all the contents to display
opts Object {} optional Options
Name Type Default Description
listCallbacks Array.<function()> null optional List of all the callback functions to excecute when pressed.
orientation OrientationWindow OrientationWindow.Vertical optional The orientation of the window (horizontal or vertical)
nbItemsMax number listContents.length optional Max number of items to display on the choice box
padding Array.<number> RPM.SMALL_SLOT_PADDING optional Padding of the box
space number 0 optional Space between each choice in the box
currentSelectedIndex number 0 optional The current selected index position in the choice box
bordersInsideVisible boolean true optional If checked, each choice will have an individual window box
Properties:
Name Type Description
listContents Array.<Object> List of all the graphic contents to display
listCallbacks Array.<function()> List of all the callback functions to excecute when pressed.
orientation OrientationWindow The orientation of the window (horizontal or vertical)
nbItemsMax number Max number of items to display on the choice box
padding Array.<number> Padding of the box
space number Space between each choice in the box
currentSelectedIndex number The current selected index position in the choice box
bordersInsideVisible boolean If checked, each choice will have an individual window box
offsetSelectedIndex number offset index position when going out of the total box size
choiceWidth number A choice box width
choiceHeight number A choice box height
startTime number A time variable used for delaying going up/down while keeping keyboard pressed
size number Max number of choices according to max number + current number
windowMain WindowBox The main window box when there is no border inside
listWindows Array.<WindowBox> List of all the windows to display

Extends

Members

WindowChoices.TIME_WAIT_PRESS number static

Number of milliseconds to wait before going up/down when keypress repeat
Default Value:
  • 50

Methods

setX (x) overrides

Set the x value
Name Type Description
x number The x value

setY (y) overrides

Set the y value
Name Type Description
y number The y value

getContent (i)Object

Get the content at a specific index
Name Type Description
i number The index
Returns:
Type Description
Object

getCurrentContent ()Object

Get the current selected content
Returns:
Type Description
Object

updateContentSize (currentSelectedIndex)

Update content size according to all the current settings
Name Type Default Description
currentSelectedIndex number 0 optional The current selected index position

setContent (i, content)

Set the content at a specific index
Name Type Description
i number The index
content Object The new content

setContents (contents)

Set all the graphic contents
Name Type Description
contents Array.<Object> All the contents

setCallbacks (callbacks)

Set all the callbacks for each choice
Name Type Description
callbacks Array.<function()> All the callbacks functions

setContentsCallbacks (contents, callbacks, currentSelectedIndex)

Set all the contents and callbacks
Name Type Default Description
contents Array.<Object> All the contents
callbacks Array.<function()> null optional All the callbacks functions
currentSelectedIndex number 0 optional The current selected index position

unselect ()

Unselect a choice

select (i)

Select a choice
Name Type Description
i number The index of the choice

selectCurrent ()

Select the current choice

goUp ()

Go cursor up

goDown ()

Go cursor down

onKeyPressed (key, base)

First key press handle
Name Type Description
key number The key ID pressed
base Object The base object to apply with callback

onKeyPressedAndRepeat (key)boolean

Key pressed repeat handle, but with a small wait after the first pressure (generally used for menus)
Name Type Description
key number The key ID pressed
Returns:
Type Description
boolean false if the other keys are blocked after it

draw ()

Draw the windows

setW (w, min) inherited overrides

Set the w value
Name Type Default Description
w number The w value
min boolean false optional If checked, transform screen value with min x y

setH (h, min) inherited overrides

Set the h value
Name Type Default Description
h number The h value
min boolean false optional If checked, transform screen value with min x y

setLeft () inherited overrides

Set the position to the left

setTop () inherited overrides

Set the position to the top

setRight () inherited overrides

Set the position to the right

setBot () inherited overrides

Set the position to the bot

setCoords (x, y, w, h) inherited overrides

Set all the coords values
Name Type Description
x number The x value
y number The y value
w number The w value
h number The h value