Browse Source

Cleanups and use the new Atomic events in Shortcuts to show usage

Josh Engebretson 9 years ago
parent
commit
372e5b823a

+ 2 - 2
Script/AtomicEditor/ui/Shortcuts.ts

@@ -30,9 +30,9 @@ class Shortcuts extends Atomic.ScriptObject {
 
 
         super();
         super();
 
 
-        this.subscribeToEvent("UIShortcut", (ev: Atomic.UIShortcutEvent) => this.handleUIShortcut(ev));
+        this.subscribeToEvent(Atomic.UIShortcutEvent ( (ev) => this.handleUIShortcut(ev)));
 
 
-        this.subscribeToEvent("KeyDown", (ev: Atomic.KeyDownEvent) => this.handleKeyDown(ev));
+        this.subscribeToEvent(Atomic.KeyDownEvent( (ev) => this.handleKeyDown(ev)));
 
 
 
 
     }
     }

+ 4 - 2
Source/AtomicJS/Javascript/JSAPI.cpp

@@ -198,7 +198,9 @@ void js_setup_prototype(JSVM* vm, const char* package, const char* classname, co
 }
 }
 
 
 
 
-static int js_define_native_event_duk(duk_context* ctx) {
+// When subscribing to native event, this method will be called
+// to provide the event meta data (type and callback)
+static int js_push_native_event_metadata(duk_context* ctx) {
 
 
     duk_push_current_function(ctx);
     duk_push_current_function(ctx);
 
 
@@ -214,7 +216,7 @@ static int js_define_native_event_duk(duk_context* ctx) {
 void js_define_native_event(duk_context* ctx, const String& eventType, const String &eventName)
 void js_define_native_event(duk_context* ctx, const String& eventType, const String &eventName)
 {
 {
     // push c function which takes 1 argument, the callback
     // push c function which takes 1 argument, the callback
-    duk_push_c_function(ctx, js_define_native_event_duk, 1);
+    duk_push_c_function(ctx, js_push_native_event_metadata, 1);
 
 
     // store the event type in the function object
     // store the event type in the function object
     duk_push_string(ctx, eventType.CString());
     duk_push_string(ctx, eventType.CString());

+ 1 - 1
Source/AtomicJS/Javascript/JSAPI.h

@@ -54,7 +54,7 @@ void js_class_push_propertyobject(JSVM* vm, const char* package, const char* cla
 void js_class_get_prototype(duk_context* ctx, const char* package, const char *classname);
 void js_class_get_prototype(duk_context* ctx, const char* package, const char *classname);
 void js_class_get_constructor(duk_context* ctx, const char* package, const char *classname);
 void js_class_get_constructor(duk_context* ctx, const char* package, const char *classname);
 
 
-// setups up a native event wrapper on module object at the top of the stack
+// setup a native event wrapper on module object at the top of the stack
 void js_define_native_event(duk_context* ctx, const String& eventType, const String& eventName);
 void js_define_native_event(duk_context* ctx, const String& eventType, const String& eventName);
 
 
 /// Pushes variant value or undefined if can't be pushed
 /// Pushes variant value or undefined if can't be pushed