Use this macro to register efficient event listeners. The %STUDIO% framework will ensure that any
event listeners registered using this macro are attached just in time, and detached when no longer needed.
Event names are unqualified and case-insensitive. Event names are resolved in the following order:
Builtin window events (see table below)
Installed GMLDOM events (available events depend on current kits configuration)
Environment events (see @env:Environment!)
Even though it is not required, you can still qualify GMLDOM events with the $DOM prefix (e.g., $DOM.onUpdateObject) and
environment events with the $ENV prefix (e.g., ~$ENV.onModelOpen). Any other %STUDIO% events must be qualified
using their respective module prefix (e.g., $WIN.onWindowChange).
The builtin window events are listed below:
Event | Description
onInit | Fires once during window initialization (before first call to ~onShow)
onExit | Fires once during window termination (after last call to ~onHide)
onShow | Fires whenever the window is exposed (applicable for boards, floating windows, and task panels)
onHide | Fires whenever the window is concealed (applicable for boards, floating windows, and task panels)
onResize | Fires whenever the window is resized
onOptionsMenu | Fires whenever the window's options menu is requested (applicable only for task panels)
onSettingsChange | Fires whenever a %STUDIO% settings value is changed
onStudioExit | Fires when the %STUDIO% is being exited
function LISTEN(name, func, scope) {
if (!name || !func) return;
var prefix = '' ;
var eventName = '' ;
if (name.indexOf(':') > 0 )
eventName = LOWER(name);
else{
var k=name.indexOf('.');
prefix = name.substring(0,k);
eventName = LOWER(name.substring(k+1));
}
if (!prefix) {
if (eventName == 'onsettingschange' || eventName == 'onstudioexit') prefix = '$CTL';
}
if (!prefix && (eventName in __WIN_LISTENERS)) {
__WIN_LISTENERS[eventName].push(func);
} else {
var domEvents = $ENV.getEventTypesTable(), modules=__WSTUDIO.$CTL.modules;
if (!prefix) prefix = (eventName in domEvents) ? '$DOM' : '$ENV';
if (prefix == '$DOM') {
if (!(eventName in domEvents)) return;
if (!(eventName in __DOM_LISTENERS)) {
if (ISEMPTY(__DOM_LISTENERS)) {
__STB_LISTENERS.push({module:modules.$ENV, name:'onModelEvent', func:__WIN_DOM_EVENTS});
}
__DOM_LISTENERS[eventName] = [];
}
__DOM_LISTENERS[eventName].push({name:eventName, func:func});
} else if (prefix in modules) {
__STB_LISTENERS.push({module:modules[prefix], name:eventName, func:func, always:(LOWER(scope) == 'always')});
}
}
}
<@func name="SETTEMP">
Sets the value of a temporary variable