GuiTextcontrol
by Mario N. Bonassin · in Torque Game Engine · 10/19/2005 (2:41 pm) · 6 replies
Is there a way to have the text of this object change based on variable? Is there some sort of setText(""); command?
About the author
#2
10/19/2005 (3:08 pm)
Another thing to do thats a bit easyer is set the "variable" Line to a name of a variable(in the gui editor)... :P then it auto updates.
#3
Jacob, where should I put that code? should I create a .cs just for it or is there somewhere else it can go?
Thanks
10/19/2005 (3:32 pm)
I tried the variable line and nothing happens. That works with guitextedit but not guitext.Jacob, where should I put that code? should I create a .cs just for it or is there somewhere else it can go?
Thanks
#4
The method I suggested needs to be used for certain cases - I had to do it for something more complicated but if you just want to fill the text control with a variable and have it update dynamically, then what kc suggested will be fine. I know it works because I use it in many places :)
10/19/2005 (4:23 pm)
Well, kc is correct, the variable field should do the trick, just make sure that you are using a global variable.The method I suggested needs to be used for certain cases - I had to do it for something more complicated but if you just want to fill the text control with a variable and have it update dynamically, then what kc suggested will be fine. I know it works because I use it in many places :)
#5
10/19/2005 (4:50 pm)
The variable option is very nice :)
#6
function setArmorOptions()
{
if($ArmorLevel > 100)
{
$ArmorLevel = 100;
}
}
This fails because the cursor is still in the edit box and the text wont change.
Here is the gui object
new GuiTextEditCtrl(ArmorLevelVal) {
profile = "GuiTextEditProfile";
horizSizing = "right";
vertSizing = "bottom";
position = "179 210";
extent = "64 18";
minExtent = "8 2";
visible = "1";
variable = "$ArmorLevel";
maxLength = "255";
historySize = "0";
password = "0";
tabComplete = "0";
sinkAllKeyEvents = "0";
};
12/27/2005 (10:54 am)
How bout if you are editing a value in the edit box then click a button to call a funciton. You test the value and if its over some limit force the text to a value. How would you update the edit text?function setArmorOptions()
{
if($ArmorLevel > 100)
{
$ArmorLevel = 100;
}
}
This fails because the cursor is still in the edit box and the text wont change.
Here is the gui object
new GuiTextEditCtrl(ArmorLevelVal) {
profile = "GuiTextEditProfile";
horizSizing = "right";
vertSizing = "bottom";
position = "179 210";
extent = "64 18";
minExtent = "8 2";
visible = "1";
variable = "$ArmorLevel";
maxLength = "255";
historySize = "0";
password = "0";
tabComplete = "0";
sinkAllKeyEvents = "0";
};
Torque 3D Owner Jacob
YourGuiTextCtrlName.setText("");is what will update the screen andwill update the actual text variable - so very likely you will have to do both.