guiText control not updating
by Andrew13 · in Torque Game Engine Advanced · 03/29/2009 (8:47 pm) · 6 replies
I am trying to update a gui text control. While a .dump of the control shows the correct value the GUI element does not update . Using TEGA 1.8.1 .
I suspect i am missing something rather basic as i appear to be using the correct methods.
GUI code playGUI.gui
set value from default.bind.cs
The echo statement tells me the value is set . if i go to the console and do range_gui.dump i can see the "text" is set to the right value but the GUI element remains at whatever i set is the playGUI.gui as the default.
Can anyone explain what i am not doing correctly here ?
I suspect i am missing something rather basic as i appear to be using the correct methods.
GUI code playGUI.gui
new GuiControl(Hud_readout) {
canSaveDynamicFields = "1";
Enabled = "1";
isContainer = "1";
HorizSizing = "right";
VertSizing = "bottom";
position = "0 300";
Extent = "1024 768";
MinExtent = "8 2";
canSave = "1";
Visible = "1";
hovertime = "1000";
new GuiControl() {
canSaveDynamicFields = "1";
Enabled = "1";
isContainer = "1";
Profile = "GuiWindowProfile";
HorizSizing = "right";
VertSizing = "bottom";
position = "24 423";
Extent = "271 39";
MinExtent = "8 2";
canSave = "1";
Visible = "1";
hovertime = "1000";
new GuiTextCtrl() {
canSaveDynamicFields = "0";
Enabled = "1";
isContainer = "0";
HorizSizing = "right";
VertSizing = "bottom";
position = "3 -2";
Extent = "85 31";
MinExtent = "8 2";
canSave = "1";
Visible = "1";
hovertime = "1000";
Docking = "Top";
Margin = "0 0 0 0";
Padding = "0 0 0 0";
AnchorTop = "1";
AnchorBottom = "0";
AnchorLeft = "1";
AnchorRight = "0";
text = "Current Position:";
maxLength = "1024";
};
new GuiTextCtrl() {
canSaveDynamicFields = "1";
Enabled = "1";
isContainer = "0";
HorizSizing = "right";
VertSizing = "bottom";
position = "4 18";
Extent = "64 26";
MinExtent = "8 2";
canSave = "1";
Visible = "1";
hovertime = "1000";
Margin = "0 0 0 0";
Padding = "0 0 0 0";
AnchorTop = "1";
AnchorBottom = "0";
AnchorLeft = "1";
AnchorRight = "0";
text = "Last Range:";
maxLength = "1024";
};
new GuiTextCtrl(cur_pos_gui) {
canSaveDynamicFields = "1";
Enabled = "1";
HorizSizing = "right";
VertSizing = "bottom";
position = "87 9";
Extent = "112 9";
MinExtent = "8 2";
canSave = "1";
Visible = "1";
hovertime = "1000";
Docking = "Top";
Margin = "0 0 0 0";
Padding = "0 0 0 0";
AnchorTop = "1";
AnchorBottom = "0";
AnchorLeft = "1";
AnchorRight = "0";
text = "00 00 00";
maxLength = "1024";
};
new GuiTextCtrl(range_gui) {
canSaveDynamicFields = "1";
Enabled = "1";
HorizSizing = "right";
VertSizing = "bottom";
position = "69 26";
Extent = "112 9";
MinExtent = "8 2";
canSave = "1";
Visible = "1";
hovertime = "1000";
Docking = "Top";
Margin = "0 0 0 0";
Padding = "0 0 0 0";
AnchorTop = "1";
AnchorBottom = "0";
AnchorLeft = "1";
AnchorRight = "0";
text = "0000";
maxLength = "1024";
};
};
};set value from default.bind.cs
echo ("range_cli " @ %val);
range_gui.setValue(%val);The echo statement tells me the value is set . if i go to the console and do range_gui.dump i can see the "text" is set to the right value but the GUI element remains at whatever i set is the playGUI.gui as the default.
Can anyone explain what i am not doing correctly here ?
#3
echo ("range_cli " @ %val);
range_gui.setText(%val);
the echo of % val is correct.
range_gui.dump shows the text = "57.7567"
which is the correct value . but the actual GUI element on screen is still blank.
I use this command in game.cs to initialize and put the dialog on screen
range_gui.setValue("0");
Canvas.pushDialog(Hud_readout);
03/31/2009 (9:42 pm)
Nope i tried that. I just tried it again using the code below which is attached to a keybind functionecho ("range_cli " @ %val);
range_gui.setText(%val);
the echo of % val is correct.
range_gui.dump shows the text = "57.7567"
which is the correct value . but the actual GUI element on screen is still blank.
I use this command in game.cs to initialize and put the dialog on screen
range_gui.setValue("0");
Canvas.pushDialog(Hud_readout);
#4
function testgui ()
{
echo ("testing gui ");
range_gui.text="0001";
echo ("testing gui 2");
range_gui.setText(0002);
this one did not work
// echo ("testing gui 3");
// range_gui.setValue=0003;
}
moveMap.bind(keyboard, h, testgui );
still same result..range_gui.dump shows the correct value but no change in the visible guiTextcntrl.
Do i have to use attach in my initialization statement ? Or am i missing something else ?
03/31/2009 (10:15 pm)
OK i created a whole new function function testgui ()
{
echo ("testing gui ");
range_gui.text="0001";
echo ("testing gui 2");
range_gui.setText(0002);
this one did not work
// echo ("testing gui 3");
// range_gui.setValue=0003;
}
moveMap.bind(keyboard, h, testgui );
still same result..range_gui.dump shows the correct value but no change in the visible guiTextcntrl.
Do i have to use attach in my initialization statement ? Or am i missing something else ?
#5
I've found that a good practice to get into to minimize headaches like that is to be more specific in your naming convention. i.e. instead of range_gui, call it Hud_readout_range_gui, or something to that effect.
04/01/2009 (1:34 am)
The most likely problem is that there's already a control with the name range_gui, and it's setting the text value in that control instead even though it may not be visible. It doesn't have to be in the same gui, just in any other gui script that has been loaded. Try giving it a different name.I've found that a good practice to get into to minimize headaches like that is to be more specific in your naming convention. i.e. instead of range_gui, call it Hud_readout_range_gui, or something to that effect.
#6
You were right. I renamed the control to stinky _fish_head...and it worked...
Nice catch thanks a ton. I am not sure i would have ever found that .
04/01/2009 (9:14 pm)
Wow ...You were right. I renamed the control to stinky _fish_head...and it worked...
Nice catch thanks a ton. I am not sure i would have ever found that .
Torque 3D Owner Andrew13
If i add
Canvas.pushDialog(Hud_readout.range_gui);
Then i get a new complete new dialog box in the wrong place but the original still does not update . This seems like the wrong solution anyway as none of the examples i have seen here in the forums have this statement. It did tell me that the fields have enough space and seem to have the correct layering .
still not sure what i am not doing correctly here