Game Development Community

OnMouseEnter

by Very Interactive Person · in Torque Game Builder · 11/12/2006 (12:38 pm) · 15 replies

I can't seem to get onMouseEnter to work on an image. I would like to create a mouse roll over effect. onMouseDown works fine, but onMouseEnter doesn't. Is this normal? How would I create a rollover effect?

#1
11/12/2006 (1:07 pm)
OnMouseEnter works only for SceneWindow object. I had similar problem in my game, and I've implemented these events for GUI objects. But unfortunately, its not that easy to make this event for scene sprites :(
#2
11/12/2006 (1:49 pm)
Crap! That really ruins it for me.... Can't believe noboday thought of this wile designing TGB. This is basic functionality!!
#3
11/12/2006 (2:13 pm)
Well, I am thinking about patching the engine to add these events to sprites too, because I missed them. I have some ideas, but need to find some time to try them :) In short, you can add a flag to each sprite (in C++ engine) and mark it anytime when the mouse is over it (and send OnMouseEnter event). And you will also need to check the mark for the sprites outside the mouse cursor, and if the mark is set for them, clear it and send OnMouseLeave event.
#4
11/13/2006 (12:12 am)
I can probably work around it by checking the mouse position, and check if its over the images. But still, that's going to be quite ugly.
Still... can't believe this isn't in TGB. I mean, the onMouseDown works, why not have the other mouse callbacks? What's the logic behind that?
#5
11/13/2006 (1:13 am)
Well, let me tell you how they handle OnMouseDown and OnMouseMove, so maybe you will understand why they didn't implement the events you need.

When OnMouseDown or OnMouseMove events are occured for the SceneWindow, they check all the sprites if the mouse cursor is over them. If so, then they invoke the necessary event for these sprites. Actually, it is easy to implement OnMouseMoveOutside event that will be invoked when the mouse is moved outside the sprite, if it can be helpful.
#6
11/13/2006 (7:09 am)
So onMouseEnter should also be easy to add. Like you said, by using a flag. Too bad I'm not a good C++ programmer, i try to stay away from the engine code as much as possible.
#7
11/13/2006 (7:21 am)
Well, I am strongly advice you to learn C++ in order to get the most from TGB (get "C++ For Dummies", its a great book to learn C++ at the average level). There are many cases when you need to modify the sources of engine to add the new features or console commands. And you will not be too limited with TGB restrictions, because you will be able to patch them out.
#8
11/14/2006 (5:10 am)
I know :(

Anyway, for now, I just wrote it in script, and it works (it's ugly code though :) )
#9
11/14/2006 (1:38 pm)
FYI, onMouseEnter and onMouseLeave callbacks are, as far as I am aware, implemented in 1.1.3 for SceneObjects and will be available in that update.

And no, sorry, no ETA at this time for 1.1.3, but I am 100% certain that this update in particular will blow everyone away.
#10
11/14/2006 (2:28 pm)
Sweet - I really wanted to post in this thread saying that but didn't know if I could ;) They're even in the docs now too(!)
#11
11/17/2006 (1:51 pm)
Hey, is it possible to implement "undo" option in GUI builder?
#12
11/17/2006 (3:17 pm)
Please do not post questions in a completely unrelated thread. Do a search on your topic, and if you do not find an appropriate answer, create a new thread.
#13
11/19/2006 (6:22 am)
How about creating trigger to change mouseenter function
. the trigger have onenter function
. i also have same problem with you
and it solved with trigger
#14
11/20/2006 (12:46 am)
Yes, I tought about using a trigger too. But I wanted to move on, so I coded it in a rather ugly way. When the mouse moves I just check if its over the sprites, i set a mouseOverFlag on them, so I can detect mouseEnter. Then I just call the onMouseEnter and onMouseLeave from there. I can always replace it later on, when I find a more elegant way to code this. But right now, I needed to move on so I can get this game done asap.
#15
11/27/2006 (5:08 am)
Ok good luck