Flex detect when mouse leaves a Canvas - apache-flex

I am trying to detect when the mouse leaves a canvas. I know about the MOUSE_LEAVE, but this seems to only be valid for the stage, not Canvas objects.
take care,
lee
P.S. I have tried the mous-out, but, for some reason, that event keeps getting triggered everytime I move the mouse.
I should probably point out that I have used the Mouse.hide() and replaced the cursor with a custom cursor.

You could use either the MouseEvent.ROLL_OUT event or MouseEvent.MOUSE_OUT.
To see what is the difference and what you should use, read this article.

Try to use mouseOut event.

Thanks everyone. The trick was to set the custom cursor's parent to mouseChildren = false. Not a practical solution for most situations, but good for this.
The problem was coming from the fact that the mouse is still on the stage and moves slightly faster than the code move the custom mouse. So if the mouse was moved too quickly, it actually moved off the custom cursor.
take care,
lee

Related

Have problem to get touch or mouseclick trigger the click event of aframe objects

I can't get my code to work to trigger a function upon a click event. Both on desktop or mobile chrome browser it doesn't work. If I enter to inspector mode I recognize that in a small area of the object I can click it and it will triggered, but if I leave the inspector (strg+alt+i) it doesn't work. it seems to me that something will not hit the right point to trigger the event. This makes me crazy.
I hope someone could give me a good hint to solve my problem. thanks in advance.
My code is online testable under https://glitch.com/~ede21-arjslocationtutorial
I did not try to edit the code but I think the problem comes from your cursor and raycaster properties. They should be on a camera entity, not on the a-scene entity. A-Frame creates a default one but you can create it yourself and set this properties. The cursor will change when you hover the entities, then it should work properly ;)

How would I be able to use my mouse to shoot

So far I've created an object called obj_mouse. And my plan is whenever the player left clicks, it spawns a bullet from him toward where ever the mouse is pointing. I've got the concept down, but I'm struggling getting it to work.
Extra bits of code I'm messing around with to try to get it to work:
bullet=instance_create(x,y,obj_bullet)
with (bullet) {
move_towards_point(mouse_x,mouse_y,5)
image_angle=direction
}
point_direction(obj_mouse,obj_mouse,obj_mouse,obj_mouse)
image_angle=direction
(In the above code, I have not attempted to specify to the program that I want the bullet to go in the direction of obj_mouse, or rather, just the mouse. The above code works, and bullets do shoot, however the player must have the mouse on the players sprite for it to work.)
Thank you in advance for any advice given.
The fix was applying the piece of code to a global mouse click event, so that it does not call the code from the object being left clicked rather it calls the code when left click is clicked.

How to receive hover events on QGraphicsItems during drop?

I use two different QGraphicView's and do drag'n'drop between them. The dragdrop does work very well so far. In one of my QGraphicView's I have items that receive hover events so that they are lighted when the mouse moves on them. The problem is that during drops and also during moves on items, the hover events won't get called. Is it possible to overcome this behaviour somehow? The hover events mark the places the drop can occur in my view and the items then have to be dropped at the right places accordingly (they can only be inserted at specific places and the user should get some feedback).
I hope I could describe my problem...I posted no code for now, because I do not know if this is even possible.
Thanks!
I'm not too familiar with the graphics view framework yet, but you'll probably need to subclass QGraphicsView (if you haven't already) and override QWidget::DragEnterEvent. Depending on how you coded your objects, they might also have a DragEnterEvent that you can use.
In either case you'd accept the QDragEnterEvent and have it trigger the hover event. Hope that points you in the right direction.

Panning QScrollArea with a mouse

I have a QScrollArea. I would like to make the context pannable with a mouse - such that, a hand cursor is shown over the area and click-and-hold gets us into dragging mode.
This would be similar to what QGraphicsView can do easily with QGraphicsView::ScrollHandDrag dragging mode, only that I need it for QScrollArea.
Any idea on how to have it out of the box? Or perhaps a piece of code to do it manually? I am certainly not the first one who wants it..
Should not be difficult, especially using event filter. Take a look at my old blog post on Flick list or kinetic scrolling (the code has been moved to http://qt.gitorious.org/qt-labs/graphics-dojo). As a bonus, you can get the momentum effect easily!
Okay. At the end I changed it to QGraphicsView and it was easy to do, worked great out of the box.

Catching an onReleaseOutside for the stage

Firstly I feel this question is not a duplicate for :
Easiest implementation of onReleaseOutside in AS3?
Now, the problem , I want to do some action when the mouse_down happened inside the stage, but the mouseup happened outside it.
e.g check google finance charts, try dragging the change range divider and then make the drag such that your mouse exists the browser screen, and then do a mouse_up outside the browser, this will trigger some action inside the stage , i.e make the range stick to the position it was, when the mouse exited the window.)
How can this be done in Flex 3/4??
Thanks,
Neeraj
Try this one:
stage.addEventListener(Event.MOUSE_LEAVE, check);

Resources