:: Home >>

setController

Assigns the controller (a collection of the related event handlers).

Syntax

obj.setController(name, value);

Parameters

name (string) - controller name
value (object) - associative array of event name/event handler pairs

Example

obj.setController("myTabKeys", {
    onKeyTab: "selectNextRow",
    onKeyShiftTab: "selectPreviousRow"
});

Remarks

There are two ways of adding event listeners to AW controls. The simple one, intended for the control users, is attaching the event handler to the object itself

obj.onCellMouseOver = eventHandlerFunction;

There is also another method, intended for the control developer, where you can attach/remove/replace a group of related event handlers, called 'controller'. The controller is just an assosiative array of eventName:eventHandlerFunction pairs

var mouseController = {
    onCellMouseOver: function1,
    onCellMouseOut: function2
};

You can assign the controller using setController(name, controllerObject) method

obj.setController("mouse", mouseController);

Several controllers can contain handlers for the same event, in this case all of them will be executed. The event handler attached directly to the object will be executed first and returning non-zero error code will cancel execution of event handlers in the controllers.

The controllers support special case where you can specify the name of other event instead of actual event handler -

var keyboardController = {
    onKeyLeft: "selectPreviousCell",
    onKeyRight: "selectNextCell"
};

var selectionController = {
    selectPreviousCell: function1,
    selectNextCell: function2
};

Comments

10 Jul 06
How to add multiple event listeners DT (5)

Comments will appear on this page and in the main forum.

Documentation:

Recent changes:

2.6.4
2.6.3
2.6.2
2.6.1
2.6.1
2.6.0
2.5.0 - 2.5.6
2.5.6
2.5.0 - 2.5.5
2.5.5