BBMOD_IEventListener.on_event

A function defined in BBMOD_IEventListener.gml

on_event([_event, ]_listener)

Description

Adds a listener for a specific event.

Arguments

Name Type Description
_event String The event name. If undefined, then the listener is executed on every event.
_listener Function A function executed when the event occurs. Should take the event data as the first argument and the event name as the second argument.

Returns

Struct.BBMOD_IEventListener Returns self.

Example

function Button() constructor
{
   BBMOD_IEventListener();
}

var _button = new Button();

/// @desc This will be always executed, no matter the event type.
_button.on_event(function (_data, _eventName) {
   show_debug_message("Got event " + string(_eventName) + "!");
});

/// @desc This will be executed only on event "click".
_button.on_event("click", function () {
   show_debug_message("The button was clicked!");
});

See also

BBMOD_IEventListener.off_event

Do you find this page helpful?

Copyright © 2024, BlueBurn. Built on April 26, 2024 using GMDoc.