Class: Controller

Controller(gui, name, labelStr, setupCallbackopt)

Base class for all GUI controllers.

Constructor

new Controller(gui, name, labelStr, setupCallbackopt)

Constructor for the Controller class.

Parameters:
Name Type Attributes Description
gui GUI

The GUI instance this controller belongs to.

name string

The name of the controller.

labelStr string

The label text for the controller.

setupCallback function <optional>

Optional callback function for setup.

Source:
Examples
// For any Controller, the main callback function passed into it will trigger when the controller is triggered, like this:
const triggerButton = new Button(
	gui,
	'buttonTrigger',
	'Do something!',
	controller => {
		doSomething();
	}
);
// You can add an optional setupCallback function which calls after the GUI item is created:
const triggerButton = new Button(
	gui,
	'buttonTrigger',
	'Do something!',
	controller => {
		doSomething();
	},
	controller => {
		// simulate a click on loading the app
		controller.click();
	}
);

Extends

Members

_doUpdateChangeSet :boolean

Static flag to control whether the change set should be updated.

Type:
  • boolean
Source:

_doUpdateChangeSet :boolean

Flag to control whether the change set should be updated.

Type:
  • boolean
Source:

console :p5.Element

The console div element for displaying messages.

Type:
  • p5.Element
Source:

consoleText :string

The current console text.

Type:
  • string
Source:

controllerElement :p5.Element|HTMLElement

The HTML element representing the controller.

Type:
  • p5.Element | HTMLElement
Source:

controllerWrapper :p5.Element

The wrapper div for the controller.

Type:
  • p5.Element
Source:

die :DieIcon

The die icon for randomization.

Type:
Source:

doRandomize :boolean

Flag to control whether the controller should randomize its value.

Type:
  • boolean
Source:

gui :GUIForP5

The GUIForP5 instance this controller belongs to.

Type:
Source:

label :string

The label for the controller.

Type:
  • string
Source:

name :string

The name of the controller.

Type:
  • string
Source:

setupCallback :function

Optional setup callback.

Type:
  • function
Source:

Methods

addDie(die)

Adds a die to the controller.

Parameters:
Name Type Description
die DieIcon

The die to add.

Source:

addToRandomizer(randomizer)

Adds this controller to a randomizer.

Parameters:
Name Type Description
randomizer Randomizer

The randomizer to add this controller to.

Source:

createConsole()

Creates the console element for the controller.

Source:

disable()

Disables the controller.

Source:

doUpdateChangeSet() → {boolean}

Checks if the change set should be updated.

Source:
Returns:
  • True if the change set should be updated, false otherwise.
Type
boolean

enable()

Enables the controller.

Source:

hide()

Hides this field by setting its display to 'none'.

Overrides:
Source:

isDisabled() → {boolean}

Checks if the controller is disabled.

Source:
Returns:
  • True if the controller is disabled, false otherwise.
Type
boolean

isHidden() → {boolean}

Checks if this field is currently hidden.

Overrides:
Source:
Returns:

True if the field is hidden, false otherwise.

Type
boolean

setConsole(text, typeopt)

Sets the console text and type.

Parameters:
Name Type Attributes Description
text string

The text to display in the console.

type string <optional>

The type of message ('error', 'warning', etc.).

Source:

setDisabled(doSetDisabled)

Sets the disabled state of the controller.

Parameters:
Name Type Description
doSetDisabled boolean

True to disable the controller, false to enable it.

Source:

setError(text)

Sets the error message in the console.

Parameters:
Name Type Description
text string

The error message to display.

Source:

setText(text)

Sets the text content of this field.

Parameters:
Name Type Description
text string

The new text content for the field.

Overrides:
Source:

setTooltip(tooltip)

Sets the tooltip text for this field.

Parameters:
Name Type Description
tooltip string

The tooltip text to set.

Overrides:
Source:

setWarning(text)

Sets the warning message in the console.

Parameters:
Name Type Description
text string

The warning message to display.

Source:

setup()

Setup for the controller.

Source:

show()

Shows this field by setting its display to '' (default).

Overrides:
Source: