Closed MHOOO closed 12 years ago
Hi Thomas,
there's no workaround for the behavior you explain. CAAT manages a scenegraph as it main data structure, so elements which lie nearer to the root element will capture mouse events, obscuring or preventing the event flow to element's that lie below them. This behavior is exactly the same as the DOM behavior. In the other hand, CAAT can handle perfect collistion detection against actor's bounding boxes. If you happened to be using rectangular images or shapes, you'd not have such problem.
In the other hand, if you can detect by code, that your element is drop inside the box, you could disable mouse input to any on-screen actor by calling actor.enableEvents(false), which will make the actor 'transparent' to mouse input.
Despite I think I understand your problem, could you post an example so i can make sure I understand you ? In the other hand, how would you suggest a solution for this problem ?
Thanks for asking, Regards,
-ibon
2012/1/24 Thomas Karolski < reply@reply.github.com
Hello there,
I am writing a simple game where the solution is to drag & drop in item into a box. The box is animated using its mouseEnter/mouseExit events. However, when I drag another item on top of the box, it no longer is being animated - probably because the dragged Actor consumes the mouse events. Is there any way around this?
Reply to this email directly or view it on GitHub: https://github.com/hyperandroid/CAAT/issues/30
Unfortunately I already fixed the problem, so I don't have an example. But the problem is really simple:
mouseEnter
on AenableDrag
Problem: As you drag B over A, A's mouseEnter
method is not being called.This is to be expected. Usually (i.e. in other event handling frameworks) however there exists some way to set an event to not be consumed after invoking a handler.
An easy way to accomplish this, would be to add a variable handled
to any event. Upon invoking a handler, say, mouseEnter
, the user could set handled
to false and return. The invoker of the handler (i.e. CAAT) would check for the handled
variable and if it is false, look for another element under the mouse to invoke mouseEnter
on.
Personally, what I did to solve my problem was different. I have overridden mouseDrag
on B to check whether the current mouse position is inside A, and if so, start the animation on A (which would usually be started by the mouseEnter handler). Then I called the default mouseDrag
function on B.
Ok,
I see your point. Will close this issue and open another one regarding some testing on the event.consumed behavior. Will get back to you with the results. Unfortunately, I can't tell when.
Thanks for the suggestion. Regards,
-ibon
2012/1/24 Thomas Karolski < reply@reply.github.com
Unfortunately I already fixed the problem, so I don't have an example. But the problem is really simple:
- Create 2 objects A & B on a scene
- Implement
mouseEnter
on A- Make B draggable by invoking
enableDrag
Problem: As you drag B over A, A'smouseEnter
method is not being called.This is to be expected. Usually (i.e. in other event handling frameworks) however there exists some way to set an event to not be consumed after invoking a handler. An easy way to accomplish this, would be to add a variable
handled
to any event. Upon invoking a handler, say,mouseEnter
, the user could sethandled
to false and return. The invoker of the handler (i.e. CAAT) would check for thehandled
variable and if it is false, look for another element under the mouse to invokemouseEnter
on.Personally, what I did to solve my problem was different. I have overridden
mouseDrag
on B to check whether the current mouse position is inside A, and if so, start the animation on A (which would usually be started by the mouseEnter handler). Then I called the defaultmouseDrag
function on B.
Reply to this email directly or view it on GitHub: https://github.com/hyperandroid/CAAT/issues/30#issuecomment-3640982
Hello there,
I am writing a simple game where the solution is to drag & drop in item into a box. The box is animated using its mouseEnter/mouseExit events. However, when I drag another item on top of the box, it no longer is being animated - probably because the dragged Actor consumes the mouse events. Is there any way around this?