Game Development Community

Checking Mouse Clicks in GUI menu system

by Leroy Frederick · in Torque Game Builder · 07/31/2006 (2:52 am) · 5 replies

Hey all,

does any1 know how i would check for Mouse clicks to allow a speed on a menu animation say?

Both sceneWindow2D::OnMouse method and testActionMap examples in input pdf don't seem to be working for me!? (Bear in mind, this is a menu system so i have yet to load a level (t2d) file

I would probaly idealy want the 'testActionMap.bind(mouse0, "button0", button0);' function for this operation, but thus far it's not picking up anything, even with the default example version 'testActionMap.bind(mouse0, "xaxis", xaxis);'

Thanks in advance!

#1
07/31/2006 (7:22 am)
To my knowledge binding any mouse button doesn't work and doesn't return any errors. I posted this in the Report Bugs section of the forums but I haven't got a response yet.

For a menu system, you'd want to save it under a GUI file, not as a level. In the GUI editor, use ButtonCtrls to navigate different choices.
Ex:
Single Player

Options

Exit


You can also make ButtonBitmapCtrls that use 4 different images for pushed, higlighted, ect.

Check this out, it has a link to a Main Menu tutorial.
#2
07/31/2006 (8:51 am)
Thanks Kevin,

I already know how to use the gui and make toggle/hl buttons etc, i just wanted a way to get Left click input while in a menu system to allow my menu animation (movement) to bypass or speed up...

thanks nonetheless :)
#3
07/31/2006 (9:16 am)
Have you enabled mouse events for the objects? Without it, the objects will not be "looking" for any mouse events.
$myObject.setUseObjectMouseEvents(true);
Here's a small guide on how to catch mouse events. Your overall code might be fine, but you might be missing a simple call such as the one mentioned above.
#4
08/01/2006 (1:46 am)
@all: Hmm, i'll take another look at some links and of the other suggestions, i've probaly missed something, Thanks again, more suggestions are welcome nonetheless :)

@Thanks Apurva, but does that code require me to load a level first (as im in a menu system (.gui) file) or am i just getting it confused :S, in anycase i'll take a look at the suggested link, thanks :)
#5
08/07/2006 (8:26 am)
Hi all,

Found a way to achieve what i want, so thought i must share in case any1 else could use it, basicially you can check mouse input via a function on gui elements such as buttons etc via the following
function GuiObject::onClick()
{ }

as a bonus, you can do the same with right clicks via
function GuiObject::onRightClick()
{ }

To achieve the menu bypass function i was originally talking about, you'd have to create a invisible clickable Gui Object (in my case a bitmap button) that's extent covers the entire screen, when have a gui animation/movement going change the set position to (0,0), in which case you can then set the function to allow the bypass click, if there is no movement/animation going, set the position of the gui object to (800,0). Of course the example above assumes a screen size of 800*600

Anyhow, thanks again for all the help folks :)