[squeak-dev] mouse enter/move/leave event confusion

tim Rowledge tim at rowledge.org
Wed Dec 2 02:30:21 UTC 2015


I’m trying to provide the appearance of a cursor that is gridded in a paint program; the idea is that the tool cursor should jump only to positions on the grid and when the bitmap is scaled to say 4X that would be every 4th pixel position on the screen.

Since making the actual HandMorph & real cursor do gridding seemed a bit of a heavyweight thing to impose on everything else, I’m attempting to do it by handling mousemove events within my painting canvas morph. It *almost* works but there is something very odd going on at far too frequent occasions.

So far as I can currently tell the event handling code up in Morph & HandMorph is sometimes deciding that the mouse has left my morph and thus sends me a mouseleave event instead of a a move. Then as soon as the cursor moves, I get a new mouseenter and more moves until whatever it is upsets things again. There’s some unpleasantly complex code up at MouseOverHandler>processMouseOver: for example that appears to be in the middle of my problem - best I can tell is that ‘leftMorphs’ is somehow including my morph when the mouse is still right there in the middle of it.

My basic scheme is to create a suitable ImageMorph on the mouseEnter, change its position with each mouseMove and then delete it on mouseLeave.  I have implemented handlesMouseMove: to always return true, so I seem to get all the move events.

Any idea about why I get the dud mouseLeave events? Has anyone else done a scaled-up-grid-cursor thingy?

tim
--
tim Rowledge; tim at rowledge.org; http://www.rowledge.org/tim
"How many Pak Protectors does it take to change a lightbulb?” 
"Only one, but the lightbulb has to smell right."





More information about the Squeak-dev mailing list