Skip to content
Devin Samarin edited this page May 9, 2011 · 1 revision

Since this is a GUI toolkit, it makes sense to have a system of signals and callbacks. That means, for example, when you click on a Button widget, an event is fired. Callbacks wait for the event to be signaled, and are then executed. Inheriting from [[suit]].Object gives the power to connect callback functions to your object while you can emit whichever ones you want.

Properties

signals

This is not to be messed with. It contains a mapping of the names of signals to the callbacks that are connected to them.

Methods

connect

Object->connect( (string) signal, (function) fn, (mixed) custom... )

Use this to connect a callback to a signal. For example, you can use this code to increase a counter when a button is activated:

var counter = {value: 0};
var button = new suit.Button("Test");

button.connect("activate", function(counter) {
	counter.value++;
}, counter);

disconnect

`Object->disconnect( (string) signal, (function) fn )```

Use this to remove a callback once one has been added.

button.disconnect("activate", my_counter_function);

emit

Object->emit( (string) signal, (mixed) custom...)

Use this to emit a signal, therefore calling each of the callbacks that are connected with the signal. You may add custom arguments which are pushed to the front of the argument list of the callback function.

button.emit("activate");

Object Hierarchy

[[suit]].Object
	+--- [[suit]].[[Widget]]
Clone this wiki locally