How can I get a Button 's position?
by Ken · in Torque Game Builder · 07/05/2005 (9:49 pm) · 3 replies
I am a beginner.so I have many questions
how can i get a button's positon when I click it?
how can i get a button's positon when I click it?
#2
but I don't know button's name for some reason when I click it .
How to judge a button be pressed? so I can get this button's name or handle.
07/05/2005 (10:26 pm)
Thank you !but I don't know button's name for some reason when I click it .
How to judge a button be pressed? so I can get this button's name or handle.
#3
You can then write a function that checks the first parameter passed in, which will be the button. So you could do
There are a number of other ways to do this as well, but if you have several buttons that you wish to perform the same operation on, the above should be ok.
07/06/2005 (4:45 am)
Yin: You can set the "command" variable of a button to a peice of script that will be run whenever the button is clicked. If you set this in the gui editor for your buttons toonButtonClicked( $ThisControl );
You can then write a function that checks the first parameter passed in, which will be the button. So you could do
function onButtonClicked( %this )
{
echo("Stop pushing my buttons" SPC %this.getPosition() );
}There are a number of other ways to do this as well, but if you have several buttons that you wish to perform the same operation on, the above should be ok.
Associate Melv May
You can find these and more in "GuiControl.cc" by searching for "ConsoleMethod" which is C++'s way of binding C++ functions to the script. Searching for this MACRO is a quick (albeit dirty) method for finding the script-bindings.
Hope this helps,
- Melv.