controllers.js

In this file you can find all controller types and their UX behavior:

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();
	}
);

Any ValuedController importantly also passes its updated value to the callback to be used elsewhere in the system. I usually link it to generator like so, also using data from generator to construct the controller:

const fgColBoxes = new ColourBoxes(
	gui, 'colourBoxesFgCol', 'Foreground colour', generator.palette, 0,
	(controller, value) => {
		generator.fgCol = value;
	}
);