can create normal events and custom events

master
Theunis J. Botha 2021-09-06 12:32:22 +02:00
parent 73ab31fa06
commit b745fa0690
13 changed files with 295 additions and 99 deletions

87
dist/r3.js vendored
View File

@ -1,6 +1,6 @@
class R3 { class R3 {
static version = '2.0.158'; static version = '2.0.163';
static compileDate = '2021 Sep 06 - 12:10:13 pm'; static compileDate = '2021 Sep 06 - 12:30:38 pm';
} }
/** /**
@ -282,11 +282,12 @@ Event.OBJECT_INITIALIZED = 0x10;
Event.PAUSE = 0x11; Event.PAUSE = 0x11;
Event.RESTART = 0x12; Event.RESTART = 0x12;
Event.START = 0x13; Event.START = 0x13;
Event.TOUCH_CANCEL = 0x14; Event.TEST_EVENT = 0x14;
Event.TOUCH_END = 0x15; Event.TOUCH_CANCEL = 0x15;
Event.TOUCH_MOVE = 0x16; Event.TOUCH_END = 0x16;
Event.TOUCH_START = 0x17; Event.TOUCH_MOVE = 0x17;
Event.MAX_EVENTS = 0x18; Event.TOUCH_START = 0x18;
Event.MAX_EVENTS = 0x19;
Event.GetEventName = function(eventId) { Event.GetEventName = function(eventId) {
@ -310,10 +311,11 @@ Event.GetEventName = function(eventId) {
case 0x11 : return 'pause'; case 0x11 : return 'pause';
case 0x12 : return 'restart'; case 0x12 : return 'restart';
case 0x13 : return 'start'; case 0x13 : return 'start';
case 0x14 : return 'touch_cancel'; case 0x14 : return 'test_event';
case 0x15 : return 'touch_end'; case 0x15 : return 'touch_cancel';
case 0x16 : return 'touch_move'; case 0x16 : return 'touch_end';
case 0x17 : return 'touch_start'; case 0x17 : return 'touch_move';
case 0x18 : return 'touch_start';
default : default :
throw new Error('Event type not defined : ' + eventId); throw new Error('Event type not defined : ' + eventId);
} }
@ -1617,6 +1619,8 @@ class Utils {
- Stop() - Stop()
Stops the system by removing these subscriptions to events Stops the system by removing these subscriptions to events
Event.TEST_EVENT
**/ **/
class SystemInput extends System { class SystemInput extends System {
@ -1643,6 +1647,13 @@ class SystemInput extends System {
*/ */
start() { start() {
this.subscriptions.push(
new Event.Subscribe(
Event.TEST_EVENT,
this.OnTestEvent
)
);
console.log('Test for custom start before'); console.log('Test for custom start before');
this.started = true; this.started = true;
@ -1657,6 +1668,16 @@ class SystemInput extends System {
*/ */
stop() { stop() {
this.subscriptions = this.subscriptions.reduce(
(result, subscription) => {
if (subscription.remove(Event.TEST_EVENT) !== true) {
result.push(subscription);
}
return result;
},
[]
);
this.started = false; this.started = false;
console.log('Stopped transient system: SystemInput'); console.log('Stopped transient system: SystemInput');
@ -1675,54 +1696,63 @@ class SystemInput extends System {
SystemInput.OnTouchStart SystemInput.OnTouchStart
) )
); );
SystemInput.Subscriptions.push( SystemInput.Subscriptions.push(
new Event.Subscribe( new Event.Subscribe(
Event.TOUCH_END, Event.TOUCH_END,
SystemInput.OnTouchEnd SystemInput.OnTouchEnd
) )
); );
SystemInput.Subscriptions.push( SystemInput.Subscriptions.push(
new Event.Subscribe( new Event.Subscribe(
Event.TOUCH_MOVE, Event.TOUCH_MOVE,
SystemInput.OnTouchMove SystemInput.OnTouchMove
) )
); );
SystemInput.Subscriptions.push( SystemInput.Subscriptions.push(
new Event.Subscribe( new Event.Subscribe(
Event.TOUCH_CANCEL, Event.TOUCH_CANCEL,
SystemInput.OnTouchCancel SystemInput.OnTouchCancel
) )
); );
SystemInput.Subscriptions.push( SystemInput.Subscriptions.push(
new Event.Subscribe( new Event.Subscribe(
Event.KEYBOARD_DOWN, Event.KEYBOARD_DOWN,
SystemInput.OnKeyboardDown SystemInput.OnKeyboardDown
) )
); );
SystemInput.Subscriptions.push( SystemInput.Subscriptions.push(
new Event.Subscribe( new Event.Subscribe(
Event.KEYBOARD_UP, Event.KEYBOARD_UP,
SystemInput.OnKeyboardUp SystemInput.OnKeyboardUp
) )
); );
SystemInput.Subscriptions.push( SystemInput.Subscriptions.push(
new Event.Subscribe( new Event.Subscribe(
Event.MOUSE_DOWN, Event.MOUSE_DOWN,
SystemInput.OnMouseDown SystemInput.OnMouseDown
) )
); );
SystemInput.Subscriptions.push( SystemInput.Subscriptions.push(
new Event.Subscribe( new Event.Subscribe(
Event.MOUSE_UP, Event.MOUSE_UP,
SystemInput.OnMouseUp SystemInput.OnMouseUp
) )
); );
SystemInput.Subscriptions.push( SystemInput.Subscriptions.push(
new Event.Subscribe( new Event.Subscribe(
Event.MOUSE_MOVE, Event.MOUSE_MOVE,
SystemInput.OnMouseMove SystemInput.OnMouseMove
) )
); );
SystemInput.Subscriptions.push( SystemInput.Subscriptions.push(
new Event.Subscribe( new Event.Subscribe(
Event.MOUSE_WHEEL, Event.MOUSE_WHEEL,
@ -1744,7 +1774,7 @@ class SystemInput extends System {
SystemInput.Subscriptions = SystemInput.Subscriptions.reduce( SystemInput.Subscriptions = SystemInput.Subscriptions.reduce(
(result, subscription) => { (result, subscription) => {
if (subscription.remove() !== true) { if (subscription.remove(Event.TOUCH_START) !== true) {
result.push(subscription); result.push(subscription);
} }
return result; return result;
@ -1754,7 +1784,7 @@ class SystemInput extends System {
SystemInput.Subscriptions = SystemInput.Subscriptions.reduce( SystemInput.Subscriptions = SystemInput.Subscriptions.reduce(
(result, subscription) => { (result, subscription) => {
if (subscription.remove() !== true) { if (subscription.remove(Event.TOUCH_END) !== true) {
result.push(subscription); result.push(subscription);
} }
return result; return result;
@ -1764,7 +1794,7 @@ class SystemInput extends System {
SystemInput.Subscriptions = SystemInput.Subscriptions.reduce( SystemInput.Subscriptions = SystemInput.Subscriptions.reduce(
(result, subscription) => { (result, subscription) => {
if (subscription.remove() !== true) { if (subscription.remove(Event.TOUCH_MOVE) !== true) {
result.push(subscription); result.push(subscription);
} }
return result; return result;
@ -1774,7 +1804,7 @@ class SystemInput extends System {
SystemInput.Subscriptions = SystemInput.Subscriptions.reduce( SystemInput.Subscriptions = SystemInput.Subscriptions.reduce(
(result, subscription) => { (result, subscription) => {
if (subscription.remove() !== true) { if (subscription.remove(Event.TOUCH_CANCEL) !== true) {
result.push(subscription); result.push(subscription);
} }
return result; return result;
@ -1784,7 +1814,7 @@ class SystemInput extends System {
SystemInput.Subscriptions = SystemInput.Subscriptions.reduce( SystemInput.Subscriptions = SystemInput.Subscriptions.reduce(
(result, subscription) => { (result, subscription) => {
if (subscription.remove() !== true) { if (subscription.remove(Event.KEYBOARD_DOWN) !== true) {
result.push(subscription); result.push(subscription);
} }
return result; return result;
@ -1794,7 +1824,7 @@ class SystemInput extends System {
SystemInput.Subscriptions = SystemInput.Subscriptions.reduce( SystemInput.Subscriptions = SystemInput.Subscriptions.reduce(
(result, subscription) => { (result, subscription) => {
if (subscription.remove() !== true) { if (subscription.remove(Event.KEYBOARD_UP) !== true) {
result.push(subscription); result.push(subscription);
} }
return result; return result;
@ -1804,7 +1834,7 @@ class SystemInput extends System {
SystemInput.Subscriptions = SystemInput.Subscriptions.reduce( SystemInput.Subscriptions = SystemInput.Subscriptions.reduce(
(result, subscription) => { (result, subscription) => {
if (subscription.remove() !== true) { if (subscription.remove(Event.MOUSE_DOWN) !== true) {
result.push(subscription); result.push(subscription);
} }
return result; return result;
@ -1814,7 +1844,7 @@ class SystemInput extends System {
SystemInput.Subscriptions = SystemInput.Subscriptions.reduce( SystemInput.Subscriptions = SystemInput.Subscriptions.reduce(
(result, subscription) => { (result, subscription) => {
if (subscription.remove() !== true) { if (subscription.remove(Event.MOUSE_UP) !== true) {
result.push(subscription); result.push(subscription);
} }
return result; return result;
@ -1824,7 +1854,7 @@ class SystemInput extends System {
SystemInput.Subscriptions = SystemInput.Subscriptions.reduce( SystemInput.Subscriptions = SystemInput.Subscriptions.reduce(
(result, subscription) => { (result, subscription) => {
if (subscription.remove() !== true) { if (subscription.remove(Event.MOUSE_MOVE) !== true) {
result.push(subscription); result.push(subscription);
} }
return result; return result;
@ -1834,7 +1864,7 @@ class SystemInput extends System {
SystemInput.Subscriptions = SystemInput.Subscriptions.reduce( SystemInput.Subscriptions = SystemInput.Subscriptions.reduce(
(result, subscription) => { (result, subscription) => {
if (subscription.remove() !== true) { if (subscription.remove(Event.MOUSE_WHEEL) !== true) {
result.push(subscription); result.push(subscription);
} }
return result; return result;
@ -1848,6 +1878,16 @@ class SystemInput extends System {
} }
/**
* OnTestEvent()
* - Listens to events of type Event.TEST_EVENT and executes this function.
* @param data (The event data passed as argument - typically an R3Object)
* @return null
*/
OnTestEvent(data) {
}
/** /**
* OnTouchStart() * OnTouchStart()
* - Listens to events of type Event.TOUCH_START and executes this function. * - Listens to events of type Event.TOUCH_START and executes this function.
@ -2058,6 +2098,7 @@ class SystemLinking extends System {
SystemLinking.OnObjectCreated SystemLinking.OnObjectCreated
) )
); );
SystemLinking.Subscriptions.push( SystemLinking.Subscriptions.push(
new Event.Subscribe( new Event.Subscribe(
Event.INSTANCE_CREATED, Event.INSTANCE_CREATED,
@ -2080,7 +2121,7 @@ class SystemLinking extends System {
SystemLinking.Subscriptions = SystemLinking.Subscriptions.reduce( SystemLinking.Subscriptions = SystemLinking.Subscriptions.reduce(
(result, subscription) => { (result, subscription) => {
if (subscription.remove() !== true) { if (subscription.remove(Event.OBJECT_CREATED) !== true) {
result.push(subscription); result.push(subscription);
} }
return result; return result;
@ -2090,7 +2131,7 @@ class SystemLinking extends System {
SystemLinking.Subscriptions = SystemLinking.Subscriptions.reduce( SystemLinking.Subscriptions = SystemLinking.Subscriptions.reduce(
(result, subscription) => { (result, subscription) => {
if (subscription.remove() !== true) { if (subscription.remove(Event.INSTANCE_CREATED) !== true) {
result.push(subscription); result.push(subscription);
} }
return result; return result;

View File

@ -1,6 +1,6 @@
{ {
"name": "r3", "name": "r3",
"version" : "2.0.158", "version" : "2.0.163",
"description": "", "description": "",
"private": true, "private": true,
"dependencies": { "dependencies": {

190
r3.php
View File

@ -640,6 +640,68 @@ function generateUpdateFromInstanceOptions($file, $tokens)
} }
function generateEventListenersStart($file, $tokens) function generateEventListenersStart($file, $tokens)
{
$token = 'CUSTOM_EVENT_LISTENERS';
$store = getTokenStore($token, $tokens);
if (sizeof($store) <= 0) {
return;
}
echo "Will be building events for $file\n";
$template = file_get_contents('src/templates/generated_event_listeners_start.template');
$updated = '';
foreach ($store as $item) {
$item = trim($item);
$eventName = preg_replace('/Event./', '', $item);
$methodName = 'ON_'.$eventName;
$methodName = to_camel_case_from_upper_underscore($methodName);
$updates = str_replace('EVENT_NAME', $item, $template);
$updates = str_replace('CALL_BACK', $methodName, $updates);
$updated .= $updates;
}
updateSection($file, 'GENERATED_EVENT_LISTENERS_START' , $updated);
}
function generateEventListenersStop($file, $tokens)
{
$token = 'CUSTOM_EVENT_LISTENERS';
$store = getTokenStore($token, $tokens);
if (sizeof($store) <= 0) {
return;
}
echo "Will be events for $file\n";
$template = file_get_contents('src/templates/generated_event_listeners_stop.template');
$updated = '';
foreach ($store as $item) {
$item = trim($item);
$updates = str_replace('EVENT_NAME', $item, $template);
$updated .= $updates;
}
updateSection($file, 'GENERATED_EVENT_LISTENERS_STOP' , $updated);
}
function generateStaticEventListenersStart($file, $tokens)
{ {
$token = 'CUSTOM_STATIC_EVENT_LISTENERS'; $token = 'CUSTOM_STATIC_EVENT_LISTENERS';
@ -674,7 +736,7 @@ function generateEventListenersStart($file, $tokens)
updateSection($file, 'GENERATED_STATIC_EVENT_LISTENERS_START' , $updated); updateSection($file, 'GENERATED_STATIC_EVENT_LISTENERS_START' , $updated);
} }
function generateEventListenersStop($file, $tokens) function generateStaticEventListenersStop($file, $tokens)
{ {
$token = 'CUSTOM_STATIC_EVENT_LISTENERS'; $token = 'CUSTOM_STATIC_EVENT_LISTENERS';
@ -856,55 +918,60 @@ function getEventListenerUpdates($template, $tokens, $token)
foreach ($store as $item) { foreach ($store as $item) {
// $detail = getMethodDetails($item); $item = trim($item);
// $argsArray = $detail['argsArray'];
// $args = $detail['args'];
// $methodTokenName = $detail['methodTokenName'];
// $methodName = $detail['methodName'];
// $comment = $detail['comment'];
// $returns = $detail['returns'];
//
// if (sizeof($argsArray) > 1) {
// $args = implode(",\n ", $argsArray);
// $args = "\n " . $args . "\n ";
// $params = implode("\n * @param ", $argsArray);
// $params = "\n * @param " . $params;
// } else if (sizeof($argsArray) === 1) {
// if ($args === '') {
// $params = $args;
// } else {
// $params = "\n * @param " . $args;
// }
// }
//
// if ($returns !== null) {
// $returns = "\n * @returns " . $returns;
// }
//
// $comment = wordwrap($comment, 110, "\n * ");
//
// $updated = $template;
//
// if ($token === 'CUSTOM_METHODS') {
// $potentialTemplate = strtolower('src/templates/' . $methodTokenName . '.template');
// } else {
// $potentialTemplate = strtolower('src/templates/static_' . $methodTokenName . '.template');
// }
//
// if (file_exists($potentialTemplate)) {
// $functionTemplate = file_get_contents($potentialTemplate);
// $updated = preg_replace('/^\s*FUNCTION_TEMPLATE/m', $functionTemplate, $updated);
// } else {
// $updated = preg_replace('/^.*?FUNCTION_TEMPLATE.*\n/m', '', $updated);
// }
//
// $updated = str_replace('METHOD_ARGS', $args, $updated);
// $updated = str_replace('METHOD_NAME_UPPERCASE', $methodTokenName, $updated);
// $updated = str_replace('METHOD_NAME', $methodName, $updated);
// $updated = str_replace('COMMENT', $comment, $updated);
// $updated = str_replace('PARAMS', $params, $updated);
// $updated = str_replace('RETURNS', $returns, $updated);
$eventName = preg_replace('/Event./', '', $item);
$methodName = 'ON_'.$eventName;
$methodTokenName = $methodName;
$methodName = to_camel_case_from_upper_underscore($methodName);
$updated = $template;
$methodArgs = 'data';
$params = "\n * @param " . $methodArgs . " (The event data passed as argument - typically an R3Object)";
$returns = "\n * @return null";
$potentialTemplate = strtolower('src/templates/' . $methodTokenName . '.template');
if (file_exists($potentialTemplate)) {
$functionTemplate = file_get_contents($potentialTemplate);
$updated = preg_replace('/^\s*FUNCTION_TEMPLATE/m', $functionTemplate, $updated);
} else {
$updated = preg_replace('/^.*?FUNCTION_TEMPLATE.*\n/m', '', $updated);
}
$updated = str_replace('METHOD_NAME_UPPERCASE', $methodTokenName, $updated);
$updated = str_replace('METHOD_NAME', $methodName, $updated);
$updated = str_replace('METHOD_ARGS', $methodArgs, $updated);
$comment = 'Listens to events of type ' . $item . ' and executes this function.';
$comment = wordwrap($comment, 110, "\n * ");
$updated = str_replace('COMMENT', $comment, $updated);
$updated = str_replace('PARAMS', $params, $updated);
$updated = str_replace('RETURNS', $returns, $updated);
$updates .= $updated;
}
return $updates;
}
function getStaticEventListenerUpdates($template, $tokens, $token)
{
$store = getTokenStore($token, $tokens);
if (sizeof($store) <= 0) {
return null;
}
$updates = '';
foreach ($store as $item) {
$item = trim($item); $item = trim($item);
@ -949,13 +1016,30 @@ function getEventListenerUpdates($template, $tokens, $token)
return $updates; return $updates;
} }
function generateEventListenerMethods($file, $tokens)
{
$token = 'CUSTOM_EVENT_LISTENERS';
$template = file_get_contents('src/templates/generated_methods.template');
$updates = getEventListenerUpdates($template, $tokens, $token);
if ($updates) {
echo "Updating event listeners.. \n";
updateSection($file, 'GENERATED_EVENT_LISTENER_METHODS', $updates);
} else {
echo "No event listeners found to generate\n";
}
}
function generateStaticEventListenerMethods($file, $tokens) function generateStaticEventListenerMethods($file, $tokens)
{ {
$token = 'CUSTOM_STATIC_EVENT_LISTENERS'; $token = 'CUSTOM_STATIC_EVENT_LISTENERS';
$template = file_get_contents('src/templates/generated_static_methods.template'); $template = file_get_contents('src/templates/generated_static_methods.template');
$updates = getEventListenerUpdates($template, $tokens, $token); $updates = getStaticEventListenerUpdates($template, $tokens, $token);
if ($updates) { if ($updates) {
echo "Updating static event listeners.. \n"; echo "Updating static event listeners.. \n";
@ -1465,6 +1549,8 @@ foreach ($files as $file) {
generateStaticMethods($file, $tokens); generateStaticMethods($file, $tokens);
generateEventListenerMethods($file, $tokens);
generateStaticEventListenerMethods($file, $tokens); generateStaticEventListenerMethods($file, $tokens);
generateInitOptions($file, $tokens); generateInitOptions($file, $tokens);
@ -1481,6 +1567,10 @@ foreach ($files as $file) {
generateEventListenersStop($file, $tokens); generateEventListenersStop($file, $tokens);
generateStaticEventListenersStart($file, $tokens);
generateStaticEventListenersStop($file, $tokens);
/** /**
* Try to restore the rest of the old data because now methods were generated. * Try to restore the rest of the old data because now methods were generated.
* If not all data restores now - a method name / token has changed and we need * If not all data restores now - a method name / token has changed and we need

View File

@ -323,11 +323,12 @@ Event.OBJECT_INITIALIZED = 0x10;
Event.PAUSE = 0x11; Event.PAUSE = 0x11;
Event.RESTART = 0x12; Event.RESTART = 0x12;
Event.START = 0x13; Event.START = 0x13;
Event.TOUCH_CANCEL = 0x14; Event.TEST_EVENT = 0x14;
Event.TOUCH_END = 0x15; Event.TOUCH_CANCEL = 0x15;
Event.TOUCH_MOVE = 0x16; Event.TOUCH_END = 0x16;
Event.TOUCH_START = 0x17; Event.TOUCH_MOVE = 0x17;
Event.MAX_EVENTS = 0x18; Event.TOUCH_START = 0x18;
Event.MAX_EVENTS = 0x19;
Event.GetEventName = function(eventId) { Event.GetEventName = function(eventId) {
@ -351,10 +352,11 @@ Event.GetEventName = function(eventId) {
case 0x11 : return 'pause'; case 0x11 : return 'pause';
case 0x12 : return 'restart'; case 0x12 : return 'restart';
case 0x13 : return 'start'; case 0x13 : return 'start';
case 0x14 : return 'touch_cancel'; case 0x14 : return 'test_event';
case 0x15 : return 'touch_end'; case 0x15 : return 'touch_cancel';
case 0x16 : return 'touch_move'; case 0x16 : return 'touch_end';
case 0x17 : return 'touch_start'; case 0x17 : return 'touch_move';
case 0x18 : return 'touch_start';
default : default :
throw new Error('Event type not defined : ' + eventId); throw new Error('Event type not defined : ' + eventId);
} }

View File

@ -1,6 +1,6 @@
class R3 { class R3 {
static version = '2.0.158'; static version = '2.0.163';
static compileDate = '2021 Sep 06 - 12:10:13 pm'; static compileDate = '2021 Sep 06 - 12:30:38 pm';
} }
//GENERATED_IMPORTS_START //GENERATED_IMPORTS_START

View File

@ -131,6 +131,13 @@ class SystemInput extends System {
//GENERATED_START_METHOD_START //GENERATED_START_METHOD_START
//GENERATED_EVENT_LISTENERS_START_START //GENERATED_EVENT_LISTENERS_START_START
this.subscriptions.push(
new Event.Subscribe(
Event.TEST_EVENT,
this.OnTestEvent
)
);
//GENERATED_EVENT_LISTENERS_START_END //GENERATED_EVENT_LISTENERS_START_END
//CUSTOM_BEFORE_SYSTEM_START_START //CUSTOM_BEFORE_SYSTEM_START_START
@ -156,6 +163,15 @@ class SystemInput extends System {
//GENERATED_STOP_METHOD_START //GENERATED_STOP_METHOD_START
//GENERATED_EVENT_LISTENERS_STOP_START //GENERATED_EVENT_LISTENERS_STOP_START
this.subscriptions = this.subscriptions.reduce(
(result, subscription) => {
if (subscription.remove(Event.TEST_EVENT) !== true) {
result.push(subscription);
}
return result;
},
[]
);
//GENERATED_EVENT_LISTENERS_STOP_END //GENERATED_EVENT_LISTENERS_STOP_END
//CUSTOM_BEFORE_SYSTEM_STOP_START //CUSTOM_BEFORE_SYSTEM_STOP_START
@ -183,60 +199,70 @@ class SystemInput extends System {
//GENERATED_STATIC_START_METHOD_START //GENERATED_STATIC_START_METHOD_START
//GENERATED_STATIC_EVENT_LISTENERS_START_START //GENERATED_STATIC_EVENT_LISTENERS_START_START
SystemInput.Subscriptions.push( SystemInput.Subscriptions.push(
new Event.Subscribe( new Event.Subscribe(
Event.TOUCH_START, Event.TOUCH_START,
SystemInput.OnTouchStart SystemInput.OnTouchStart
) )
); );
SystemInput.Subscriptions.push( SystemInput.Subscriptions.push(
new Event.Subscribe( new Event.Subscribe(
Event.TOUCH_END, Event.TOUCH_END,
SystemInput.OnTouchEnd SystemInput.OnTouchEnd
) )
); );
SystemInput.Subscriptions.push( SystemInput.Subscriptions.push(
new Event.Subscribe( new Event.Subscribe(
Event.TOUCH_MOVE, Event.TOUCH_MOVE,
SystemInput.OnTouchMove SystemInput.OnTouchMove
) )
); );
SystemInput.Subscriptions.push( SystemInput.Subscriptions.push(
new Event.Subscribe( new Event.Subscribe(
Event.TOUCH_CANCEL, Event.TOUCH_CANCEL,
SystemInput.OnTouchCancel SystemInput.OnTouchCancel
) )
); );
SystemInput.Subscriptions.push( SystemInput.Subscriptions.push(
new Event.Subscribe( new Event.Subscribe(
Event.KEYBOARD_DOWN, Event.KEYBOARD_DOWN,
SystemInput.OnKeyboardDown SystemInput.OnKeyboardDown
) )
); );
SystemInput.Subscriptions.push( SystemInput.Subscriptions.push(
new Event.Subscribe( new Event.Subscribe(
Event.KEYBOARD_UP, Event.KEYBOARD_UP,
SystemInput.OnKeyboardUp SystemInput.OnKeyboardUp
) )
); );
SystemInput.Subscriptions.push( SystemInput.Subscriptions.push(
new Event.Subscribe( new Event.Subscribe(
Event.MOUSE_DOWN, Event.MOUSE_DOWN,
SystemInput.OnMouseDown SystemInput.OnMouseDown
) )
); );
SystemInput.Subscriptions.push( SystemInput.Subscriptions.push(
new Event.Subscribe( new Event.Subscribe(
Event.MOUSE_UP, Event.MOUSE_UP,
SystemInput.OnMouseUp SystemInput.OnMouseUp
) )
); );
SystemInput.Subscriptions.push( SystemInput.Subscriptions.push(
new Event.Subscribe( new Event.Subscribe(
Event.MOUSE_MOVE, Event.MOUSE_MOVE,
SystemInput.OnMouseMove SystemInput.OnMouseMove
) )
); );
SystemInput.Subscriptions.push( SystemInput.Subscriptions.push(
new Event.Subscribe( new Event.Subscribe(
Event.MOUSE_WHEEL, Event.MOUSE_WHEEL,
@ -271,7 +297,7 @@ class SystemInput extends System {
SystemInput.Subscriptions = SystemInput.Subscriptions.reduce( SystemInput.Subscriptions = SystemInput.Subscriptions.reduce(
(result, subscription) => { (result, subscription) => {
if (subscription.remove() !== true) { if (subscription.remove(Event.TOUCH_START) !== true) {
result.push(subscription); result.push(subscription);
} }
return result; return result;
@ -281,7 +307,7 @@ class SystemInput extends System {
SystemInput.Subscriptions = SystemInput.Subscriptions.reduce( SystemInput.Subscriptions = SystemInput.Subscriptions.reduce(
(result, subscription) => { (result, subscription) => {
if (subscription.remove() !== true) { if (subscription.remove(Event.TOUCH_END) !== true) {
result.push(subscription); result.push(subscription);
} }
return result; return result;
@ -291,7 +317,7 @@ class SystemInput extends System {
SystemInput.Subscriptions = SystemInput.Subscriptions.reduce( SystemInput.Subscriptions = SystemInput.Subscriptions.reduce(
(result, subscription) => { (result, subscription) => {
if (subscription.remove() !== true) { if (subscription.remove(Event.TOUCH_MOVE) !== true) {
result.push(subscription); result.push(subscription);
} }
return result; return result;
@ -301,7 +327,7 @@ class SystemInput extends System {
SystemInput.Subscriptions = SystemInput.Subscriptions.reduce( SystemInput.Subscriptions = SystemInput.Subscriptions.reduce(
(result, subscription) => { (result, subscription) => {
if (subscription.remove() !== true) { if (subscription.remove(Event.TOUCH_CANCEL) !== true) {
result.push(subscription); result.push(subscription);
} }
return result; return result;
@ -311,7 +337,7 @@ class SystemInput extends System {
SystemInput.Subscriptions = SystemInput.Subscriptions.reduce( SystemInput.Subscriptions = SystemInput.Subscriptions.reduce(
(result, subscription) => { (result, subscription) => {
if (subscription.remove() !== true) { if (subscription.remove(Event.KEYBOARD_DOWN) !== true) {
result.push(subscription); result.push(subscription);
} }
return result; return result;
@ -321,7 +347,7 @@ class SystemInput extends System {
SystemInput.Subscriptions = SystemInput.Subscriptions.reduce( SystemInput.Subscriptions = SystemInput.Subscriptions.reduce(
(result, subscription) => { (result, subscription) => {
if (subscription.remove() !== true) { if (subscription.remove(Event.KEYBOARD_UP) !== true) {
result.push(subscription); result.push(subscription);
} }
return result; return result;
@ -331,7 +357,7 @@ class SystemInput extends System {
SystemInput.Subscriptions = SystemInput.Subscriptions.reduce( SystemInput.Subscriptions = SystemInput.Subscriptions.reduce(
(result, subscription) => { (result, subscription) => {
if (subscription.remove() !== true) { if (subscription.remove(Event.MOUSE_DOWN) !== true) {
result.push(subscription); result.push(subscription);
} }
return result; return result;
@ -341,7 +367,7 @@ class SystemInput extends System {
SystemInput.Subscriptions = SystemInput.Subscriptions.reduce( SystemInput.Subscriptions = SystemInput.Subscriptions.reduce(
(result, subscription) => { (result, subscription) => {
if (subscription.remove() !== true) { if (subscription.remove(Event.MOUSE_UP) !== true) {
result.push(subscription); result.push(subscription);
} }
return result; return result;
@ -351,7 +377,7 @@ class SystemInput extends System {
SystemInput.Subscriptions = SystemInput.Subscriptions.reduce( SystemInput.Subscriptions = SystemInput.Subscriptions.reduce(
(result, subscription) => { (result, subscription) => {
if (subscription.remove() !== true) { if (subscription.remove(Event.MOUSE_MOVE) !== true) {
result.push(subscription); result.push(subscription);
} }
return result; return result;
@ -361,7 +387,7 @@ class SystemInput extends System {
SystemInput.Subscriptions = SystemInput.Subscriptions.reduce( SystemInput.Subscriptions = SystemInput.Subscriptions.reduce(
(result, subscription) => { (result, subscription) => {
if (subscription.remove() !== true) { if (subscription.remove(Event.MOUSE_WHEEL) !== true) {
result.push(subscription); result.push(subscription);
} }
return result; return result;
@ -386,6 +412,22 @@ class SystemInput extends System {
//GENERATED_STATIC_METHODS_END //GENERATED_STATIC_METHODS_END
//GENERATED_EVENT_LISTENER_METHODS_START //GENERATED_EVENT_LISTENER_METHODS_START
/**
* OnTestEvent()
* - Listens to events of type Event.TEST_EVENT and executes this function.
* @param data (The event data passed as argument - typically an R3Object)
* @return null
*/
OnTestEvent(data) {
//GENERATED_ON_TEST_EVENT_METHOD_START
//GENERATED_ON_TEST_EVENT_METHOD_END
//CUSTOM_ON_TEST_EVENT_METHOD_START
//CUSTOM_ON_TEST_EVENT_METHOD_END
}
//GENERATED_EVENT_LISTENER_METHODS_END //GENERATED_EVENT_LISTENER_METHODS_END
//GENERATED_STATIC_EVENT_LISTENER_METHODS_START //GENERATED_STATIC_EVENT_LISTENER_METHODS_START

View File

@ -177,12 +177,14 @@ class SystemLinking extends System {
//GENERATED_STATIC_START_METHOD_START //GENERATED_STATIC_START_METHOD_START
//GENERATED_STATIC_EVENT_LISTENERS_START_START //GENERATED_STATIC_EVENT_LISTENERS_START_START
SystemLinking.Subscriptions.push( SystemLinking.Subscriptions.push(
new Event.Subscribe( new Event.Subscribe(
Event.OBJECT_CREATED, Event.OBJECT_CREATED,
SystemLinking.OnObjectCreated SystemLinking.OnObjectCreated
) )
); );
SystemLinking.Subscriptions.push( SystemLinking.Subscriptions.push(
new Event.Subscribe( new Event.Subscribe(
Event.INSTANCE_CREATED, Event.INSTANCE_CREATED,
@ -218,7 +220,7 @@ class SystemLinking extends System {
SystemLinking.Subscriptions = SystemLinking.Subscriptions.reduce( SystemLinking.Subscriptions = SystemLinking.Subscriptions.reduce(
(result, subscription) => { (result, subscription) => {
if (subscription.remove() !== true) { if (subscription.remove(Event.OBJECT_CREATED) !== true) {
result.push(subscription); result.push(subscription);
} }
return result; return result;
@ -228,7 +230,7 @@ class SystemLinking extends System {
SystemLinking.Subscriptions = SystemLinking.Subscriptions.reduce( SystemLinking.Subscriptions = SystemLinking.Subscriptions.reduce(
(result, subscription) => { (result, subscription) => {
if (subscription.remove() !== true) { if (subscription.remove(Event.INSTANCE_CREATED) !== true) {
result.push(subscription); result.push(subscription);
} }
return result; return result;

View File

@ -0,0 +1,7 @@
this.subscriptions.push(
new Event.Subscribe(
EVENT_NAME,
this.CALL_BACK
)
);

View File

@ -0,0 +1,9 @@
this.subscriptions = this.subscriptions.reduce(
(result, subscription) => {
if (subscription.remove(EVENT_NAME) !== true) {
result.push(subscription);
}
return result;
},
[]
);

View File

@ -1,3 +1,4 @@
SYSTEM_NAME.Subscriptions.push( SYSTEM_NAME.Subscriptions.push(
new Event.Subscribe( new Event.Subscribe(
EVENT_NAME, EVENT_NAME,

View File

@ -1,7 +1,7 @@
SYSTEM_NAME.Subscriptions = SYSTEM_NAME.Subscriptions.reduce( SYSTEM_NAME.Subscriptions = SYSTEM_NAME.Subscriptions.reduce(
(result, subscription) => { (result, subscription) => {
if (subscription.remove() !== true) { if (subscription.remove(EVENT_NAME) !== true) {
result.push(subscription); result.push(subscription);
} }
return result; return result;

View File

@ -19,6 +19,7 @@ GENERATED_INDEX_BODY
GENERATED_INHERITED GENERATED_INHERITED
GENERATED_METHOD_NAME_UPPERCASE_METHOD GENERATED_METHOD_NAME_UPPERCASE_METHOD
GENERATED_METHODS GENERATED_METHODS
GENERATED_ON_TEST_EVENT_METHOD
GENERATED_OPTIONS_INIT GENERATED_OPTIONS_INIT
GENERATED_START_METHOD GENERATED_START_METHOD
GENERATED_STATIC_ASYNC_METHOD GENERATED_STATIC_ASYNC_METHOD
@ -68,6 +69,7 @@ CUSTOM_INSTANCE_OPTIONS_MAPPING
CUSTOM_LINKED_OBJECTS CUSTOM_LINKED_OBJECTS
CUSTOM_METHOD_NAME_UPPERCASE_METHOD CUSTOM_METHOD_NAME_UPPERCASE_METHOD
CUSTOM_METHODS CUSTOM_METHODS
CUSTOM_ON_TEST_EVENT_METHOD
CUSTOM_OPTIONS CUSTOM_OPTIONS
CUSTOM_OPTIONS_INIT CUSTOM_OPTIONS_INIT
CUSTOM_OUT_OF_CLASS_IMPLEMENTATION CUSTOM_OUT_OF_CLASS_IMPLEMENTATION

View File

@ -1 +1 @@
2.0.158 2.0.163