Pic changing in gui on btn press
by Foestar · in Torque 3D Professional · 02/02/2012 (2:28 pm) · 9 replies
Ummm, am I missing something? I am trying to make it so when I press a button the text in a textctrl changes. That worked...... but I also want a picture on the gui to change as well. So I used;
%ChooseClassWindow->CurrentPreview.setBitmap("game/art/gui/heart");and different attempts of similar code. But so far nothing I do will change the picture beyond what it starts as. I've looked it up and seen other people use similar codes, but not sure if it worked for them but it's no go on mine so far.About the author
Foestar Entertainment Biohazard Entertainment
#2
<input> (0): Unable to find object: '0' attempting to call function 'setBitmap'
Not sure what that means entirely. I now know it's not finding something. But what is the '0' variable it's looking for? Not sure, still trying to figure it out.
02/02/2012 (5:56 pm)
Yeah, still didn't do anything. I've actually tried a couple of different pictures and I'm not sure if it's a directory problem maybe so it's just not finding the picture I think. Checked the console, it said:<input> (0): Unable to find object: '0' attempting to call function 'setBitmap'
Not sure what that means entirely. I now know it's not finding something. But what is the '0' variable it's looking for? Not sure, still trying to figure it out.
#3
This works for me.
02/02/2012 (6:04 pm)
I'd suggest it's your "%ChooseClassWindow->", I don't even know what "->" is ...This works for me.
inUseImage.setBitmap("art/gui/yorks/inventory/empty");
#4
It must be me using that wrong though. Because you're style worked. But maybe it's done like other scripting with "." and "/" and I just didn't understand the examples.
Either way, got it working. Thanks!
EDIT: I'm gonna have to sit down and reread about Operators and Commands in torque again.
02/02/2012 (6:54 pm)
The "->" I noticed was used in other set ups of examples. Like the chooselvldlg.gui of the examples uses it like a "/" when choosing a parent or child. At least that's what I think it is after exploring the example folders.It must be me using that wrong though. Because you're style worked. But maybe it's done like other scripting with "." and "/" and I just didn't understand the examples.
Either way, got it working. Thanks!
EDIT: I'm gonna have to sit down and reread about Operators and Commands in torque again.
#5
02/03/2012 (12:07 am)
The "->" operator is a C++ operator. It is used for accessing functions of an object with a pointer. If you saw examples then they are most likely C++ examples. I believe everything in TS is accessed with a "." to access functions and attributes. I am guessing the console thought you were trying to access an object named "%ChooseClassWindow->CurrentPreview" rather than an attribute named CurrentPreview of the %ChooseClassWindow object.
#6
02/03/2012 (6:41 am)
Quote:The "->" and "-->" operators were added to Torque script for Torque 3D. Its just syntactic sugar for findObjectByInternalName()
The "->" operator is a C++ operator. It is used for accessing functions of an object with a pointer. If you saw examples then they are most likely C++ examples.
Quote:
MySimSet->SomeInternalName is the same as MySimSet.findObjectByInternalName( "SomeInternalName", false ).
MySimSet-->SomeInternalName is the same as MySimSet.findObjectByInternalName( "SomeInternalName", true ).
Using this techinque with internal names is preferable to spamming the global TorqueScript object namespace with all sorts of GUI objects. Instead you only give names to top level GUI elements and use -> or --> to grab children on demand.
Quote:
--> is used when trying to access a child control by it's internal name
%this-->InspectorWindow // %this is the parent // InspectorWindow is the child control's internal name
#7
02/03/2012 (6:47 am)
Instead of changing the button image through script, you could also use the GUI's Active, Inactive, Hover, and Pressed/BtnDown state image(s) system for buttons.
#8
02/03/2012 (11:48 am)
Ah, good to know. I thought it had something to do with parents and child access.
#9
02/04/2012 (8:15 am)
In the Documentation under GUI Editor > Tutorials you'll find a series of 6 articles that should help you get up to speed on the GUI system. Admitted, it's not all-encompassing, but it should set you on the path.
Associate Steve Acaster
[YorkshireRifles.com]