Game Development Community

On3DMouseDown

by Jay Barnson · in Torque Game Engine · 01/17/2005 (8:17 am) · 6 replies

I fiddled with this for a couple of hours last night, but without success (yet) - if someone can point me in the right direction I'd appreciate it.

The Scoop: I have incorporated the RTS starter kit with my existing project, rather than the other way around. I created a new GUI for the game as an RTSTSGameGui (or whatever it's called - I'm at work right now and don't have access to the code).

The problem is that I'm not getting calls to On3DMouseDown or On3DRightMouseDown at all. Those events just aren't firing. I AM getting On3DMouseMove calls, however, which is why I am confused - some mouse events are firing, others are not.

I've gone back to the TSEditGUI (again, I forget the exact names - please forgive me if I'm totally butchering them) to see where those events are generated. I can't remember if I checked whether or not the basic OnMouseDown event was being fired or not - it was getting pretty late when I knocked it off last night.

So can anyone point me in the right direction with some ideas on what I might be doing wrong?

About the author

Jay has been a mainstream and indie game developer for a... uh, long time. His professional start came in 1994 developing titles for the then-unknown and upcoming Sony Playstation. He runs Rampant Games and blogs at Tales of the Rampant Coyote.


#1
01/17/2005 (9:16 am)
No idea why the button events aren't going through, but I did trace this out a while back. It starts in gui/guiCanvas.cc with GuiCanvas::processInputEvent, where it is transfered to the specific button events, like rootMouseDown, etc. which then runs down through the classes: GuiControl, GuiTSCtrl, EditTSCtrl, then finally GuiRTSTSCtrl.

If the clicks aren't coming through at all, have you modified the game's gui"s? I ask because if you are pressing the button while over a different gui then the rts control, it will git the button event rather then the rts control.
#2
01/17/2005 (10:47 am)
Hmm... in theory, I'm going through the new GUI... it's theoretically possible that the old one could still be running in the background and capturing some input events. Any idea how I'd check that out? (I'm really looking forward to losing my newbie status on Torque).
#3
01/17/2005 (3:21 pm)
Yes I think there should be a way to do it...

the rtsGui onXXXdown calls a console function. A script function with a generic name of GuiRTSTSCtrl::onXXXDown() will catch all those calls, however the function is actually called on the objects ID, so you can use a name to diferentiate between the two...

In your scripts gui definitions, find the two: new GuiRTSTSCtrl(NNN), where the NNN is ensure that each uses a different name, then use that name instead of GuiRTSTSCtrl for sets of ::onXXXDown functions. then you can simply have different echos in each.

Hmm, or better yet, don't bother with new functons, just add to the top of GuiRTSTSCtrl::onMouseDown a getName() echo...

echo(%this.getName());

It should work.
#4
01/18/2005 (1:18 am)
Okay - I found the problem. Thanks for pointing me in the right direction.

The problem was that I had a GUIShapeNameHUD over the top of the RTS GUI - that was intercepting the mouse clicks and not passing them on.
#5
01/18/2005 (10:38 pm)
Somebody ought to write some mouse-event tracing code so you can see what's eating your events.
#6
01/19/2005 (8:23 am)
I've seen a lot of posts about the GuiShapeNameHud blocking mouse clicks and holding people up. Our team worked through all the bumps of getting the mouse to work with the 3d world and GUI at the same time a whilie back, and the first thing we hit was the GuiShapeNameHud.

Maybe someone could do up a resource, a warning, or something in HEAD to help people avoid this problem? I suppose it is a little thing, but it seems to snag a lot of people and hold them up, and it would be nice if that problem wasn't there, although I guess you get to learn about the GUI code more when it happens.

I'm thinking a resource that would allow you to forward all (or some) mouse GUI events to any other guiControl would be nice. Right now, we have all of our clicks being received by the GUiShapeNameHud, and we pass the mouse events to the root GUI, where the functionality is. Then, we put all our controls that we want to receive clicks in the HUD about the GuiShapeNameHud, and all the graphical candy or text readouts below the GuiShapeNameHud, so they won't block the game from receiving clicks. If that makes sense. :)