I have a little issue related to the events MOUSE_MOVE and TransformGestureEvent.GESTURE_ZOOM.
I want to distinguish both events, when I'm zooming an object MOUSE_MOVE should not act.
In the functions of both events, I start indicating event.stopPropagation(); but no success, so if I press with one finger and move, the MOUSE_MOVE Event should work, but when I press with two fingers, MOUSE_MOVE should not work.
Is there any way that when i could prevent MOUSE_MOVE Event act when I'm Zooming the object?
You could try event.stopImmediatePropagation(). I'm not sure what order the events you are describing fire in, though, so even this may not work. event.preventDefault() may also help.
Docs for it are here: http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/events/Event.html#stopImmediatePropagation%28%29
and here:
http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/events/Event.html#preventDefault%28%29
You should be able to check the event.cancelable Boolean property to see if the default behaviour can be prevented or not.
Related
Trying to use libgdx's drag listener, I realized that the #cancel method would only be called AFTER #dragStop even if ESC is pressed before the mouse button release, which is practically preventing me from cancelling the action meanwhile.
So how am I supposed to deal with my selection cancellation? With an additional keyboard input listener, perhaps?
So what is the functional point with the cancel method?
Thanks for any lights here.
For now, I'll just be checking up Gdx.input.isKeyPressed(Input.Keys.ESCAPE) at render time, not using #cancel anymore.
happy new year 2017!!
I want check which elememt is owner of event.
for example, basically mouse wheel event handler(owner) is body element.
if I had several vertical scrollbar, mouse wheel event handler will be changed.
please tell me how to print event owner(especially mouse wheel event).
Thanks!
The event Object has several properties. You are looking for currentTarget or target, depending on how you registered the event handler and which element actually called it.
You can play with them to see.
Will make this brief, I have a game map with units on it and had finalized a fully interactive minimap where the units on the minimap have event listeners for rollover/rollout (displays a small popup unit data summary) and click (selects the "real" unit on the main game map and scrolls the viewpoint to that location). All done, tested, working.
I then implement an interactive scrollable unit list with more status summary data and dozens of objects with rollover/rollout/click listeners. All tested and working fine.
Then I go back and look at my minimap, and the listeners on the mini-ships aren't working anymore. Things tried:
Debug code to make sure listeners still being added
Debug to watch the one place where I remove those listeners to make sure that ain't happening unexpectedly
Debug to watch all the places I refresh that dialog to make sure every iteration adds the listeners back
Can't see that there is any transparent object on top intercepting
Checked mini-ship parents to make sure I didn't turn off mouseChildren or something like that somewhere
No added stage-level listener, in fact I killed all of them temporarily to test this
What happens when I debug with a breakpoint on the mini-ship listener handler is nada. It's no longer receiving mouse events. So either something I haven't thought of has stopped them from listening or something I don't know of is intercepting.
So what is the strategy here? How can I find the break in the chain?
Well knowing what the actual problem was certainly gives us the advantage of hindsight... that being said, you could have detected the error by adding a trace call inside your function that adds the listener and another one inside your function that removes it. Then you would have seen that it isn't getting re-added. Or you could set break points there.
I need to know when a document(screen) is popped off the stack in an Apple tvOS app. I thought detecting the Menu button press would be the simplest way, but I'm using TVJS and have not been able to figure out how to write the event handler.
Please help me write an event handler that will fire on document removal, menu button press or offer an alternative solution.
Subscribe to the event unload - it's triggered whenever a page disappears after being popped from the stack:
doc.addEventListener("unload", Presenter.onUnload.bind(Presenter));
[...]
onUnload: function(event) {
console.log("onUnload");
},
There is such thing of a handler for onDocumentRemoval or similar. What you can do, instead, is create a global select handler:
doc.addEventListener("select", self.doThing.bind(self));
And then check if the fired event comes from one of the buttons used to remove an element of the stack (let's suppose those buttons have a class named delete:
doThing: function(event){
var element = event.target;
if (element.getAttribute("class").contains("delete")){
//enter code here
}
EDIT 1:
I found the possible events the TVMLKit handles (I know it is in Swift/Objective-C, but the events are the same):
TVElementTypePlay
A play event has been dispatched.
TVElementTypeSelect
A select event has been dispatched.
TVElementTypeHoldSelect
A hold event has been dispatched.
TVElementTypeHighlight
A highlight event has been dispatched.
TVElementTypeChange
A change event has been dispatched.
Those events are only attachable to a template as far as I could test. I guessed the change event would be perfect if I could attach it to the navigationDocument to listen for changes, but those two options won't work and both fire errors:
Attached to the global:
navigationDocument.addEventListener("change", function(event){console.log(event)});
Attached to the documents array:
navigationDocument.documents.addEventListener("change", function(event){console.log(event)});
There is no built-in method for those above to listen for any change. The event, though, will work on a template listening to internal changes. But it won't fire when the template is pushed to or popped from the stack.
I am guessing you will need to re-design your app in order to achieve what you are looking for.
If the mouse is over an object before and while a MOUSE_OVER event is registered, does it trigger? I ask this because it appears that it doesn't in my program, and I want to know if this is a universal behavior of all MOUSE_OVER events. Is there a way around this?
I'm gonna avoid giving a code example here, because my program is large and complicated.
The MOUSE_OVER event will dispatch whenever the cursor enters the bounds of any interactive DisplayObject, such as a Sprite or MovieClip; this includes any of its children (see ROLL_OVER if you wish to ignore children).
As well, the event will dispatch in cases where an object is added to the stage and currently happens to be under the cursor.
It is important to make sure that your event listener has been registered before the Flash Player has dispatched the event -- system events are not queued beyond a single frame, and thus no handlers will be invoked for previous activity.