How do I access the stage from a Mediator?
I was originally registering for mouse licks in my mediator on the associated view. Now we want to just simply capture all mouse clicks on a page (regardless of control you're over). My understanding is this is accomplished by:
stage.addEventListener(MouseEvent.CLICK, onTargetClick);
I do not have stage in my mediator and I am not sure how to get it. Or is there a better way to get "global" events from within the Mediator?
Thanks,
Darryl
Comments are currently closed for this discussion. You can start a new one.
Keyboard shortcuts
Generic
? | Show this help |
---|---|
ESC | Blurs the current field |
Comment Form
r | Focus the comment reply box |
---|---|
^ + ↩ | Submit the comment |
You can use Command ⌘
instead of Control ^
on Mac
Support Staff 1 Posted by Ondina D.F. on 06 Mar, 2017 03:48 PM
Hey Darryl,
For some reasons, your message has landed in the 'spam' folder of this forum. I restored it today.
This would be one solution:
If the view is going to be removed from stage at some point, you'd need to explicitly remove the listener inside of the destroy() method, as shown above. The reason for that is that a mediator which keeps a reference to its view can't be destroyed.
Another solution would be to let the view listen for the MouseEvent and in the handler of the event dispatch a custom event to which the mediator would listen:
In this case, you don't need to remove the event listener inside of destroy(), the mediator will take care of it automatically.
I'd prefer the second solution.
I hope this helps.
Ondina
Ondina D.F. closed this discussion on 13 Apr, 2017 02:34 PM.