I've spent many hours bumbling around experimenting, and I was wondering if it's possible to have a global Event Dispatcher in a plugin.
For example, in the loader function, I create a class inherited from GEventDispatcherProxy, and store the address of that class in a lua global variable.
Then I could call the dispatch event from any Objective C method, and I wouldn't have to bind things all the time.
I've tried various ways of doing this, and it doesn't work
. ie, it looks like it is dispatching the event, and the lua stack all looks good, but Gideros never receives the event.
The main difference I can see, when tracing this funky global one vs my sample plugin, is that my GEventDispatcherProxy class doesn't have an EventBinderMap reference, but I don't know what that is. (I'm guessing that I have to bind things all the time and this whole premise is unsupportable)
Comments
I was thinking about the inheriting Application class from EventDispatcher so that many single events can be dispatched through application object.
(GEventDispatcherProxy doesn't have EventBinderMap but the instance returned by calling GEventDispatcherProxy::object() does have.)
I've created a simple example. This example creates an 'OneSec' class and an 'onesec' object and uses NSTimer to dispatch "complete" event at every second. If you want, we can discuss tiny details of this plugin in this thread.
Likes: Caroline
Excellent example of a simple plugin.
Now to see what havoc I can wreak with this...