Problem with GUIMLTextCtrl
by B. Burton · in Torque Game Engine · 03/25/2008 (1:46 pm) · 5 replies
I'm having a problem with the guiMLtextCtrl.
Actually, I'm having 2 problems:
1) It won't close and pop to return the screen to normal.
2) I want to be able to click on another part of the screen and use the chat dialog, but it's not working either.
I am sure that it is something that I'm just overlooking, but I would appreciate any help!
Here is my code:
My gui:
I haven't finished the save and load functions. I would like to get the rest working first (but any help and advice on those will be happily accepted!).
Brian
Actually, I'm having 2 problems:
1) It won't close and pop to return the screen to normal.
2) I want to be able to click on another part of the screen and use the chat dialog, but it's not working either.
I am sure that it is something that I'm just overlooking, but I would appreciate any help!
Here is my code:
My gui:
// GUI for ProgramHud
//--- OBJECT WRITE BEGIN ---
new GuiControl(ProgramHud) {
canSaveDynamicFields = "0";
Profile = "GuiDefaultProfile";
HorizSizing = "width";
VertSizing = "height";
position = "0 0";
Extent = "1024 768";
MinExtent = "8 8";
canSave = "1";
Visible = "1";
hovertime = "1000";
textOffset = "5 5";
new GuiBitmapBorderCtrl(ProgramHud_Frame) {
canSaveDynamicFields = "0";
Profile = "GuiDefaultProfile";
HorizSizing = "width";
VertSizing = "height";
position = "0 280";
Extent = "1000 483";
MinExtent = "8 8";
canSave = "1";
Visible = "1";
hovertime = "1000";
new GuiScrollCtrl(ML_DIALOGUE_SCROLL) {
canSaveDynamicFields = "0";
Profile = "GuiScrollProfile";
HorizSizing = "width";
VertSizing = "height";
position = "15 60";
Extent = "970 405";
MinExtent = "8 8";
canSave = "1";
Visible = "1";
hovertime = "1000";
willFirstRespond = "1";
hScrollBar = "alwaysOn";
vScrollBar = "alwaysOn";
constantThumbHeight = "0";
childMargin = "0 0";
new GuiMLTextEditCtrl(ML_Code_Text) {
canSaveDynamicFields = "0";
Profile = "GuiTextEditProfile";
HorizSizing = "width";
VertSizing = "height";
position = "2 2";
Extent = "965 405";
MinExtent = "8 8";
canSave = "1";
Visible = "1";
AltCommand = "$ThisControl.eval();"; //Do I want this???
hovertime = "1000";
lineSpacing = "2";
allowColorChars = "0";
maxChars = "-1";
escapeCommand = "ProgramHud.onEscape();";
};
};
};
new GuiTextCtrl() {
profile = "GuiTextProfile";
horizSizing = "right";
vertSizing = "bottom";
position = "15 300";
extent = "63 18";
minExtent = "8 8";
visible = "1";
text = "Bot Name:";
maxLength = "255";
helpTag = "0";
};
new GuiBitmapCtrl() {
canSaveDynamicFields = "0";
Profile = "GuiDefaultProfile";
HorizSizing = "width";
VertSizing = "height";
position = "80 295";
Extent = "150 30";
MinExtent = "8 8";
canSave = "1";
Visible = "1";
hovertime = "1000";
bitmap = "./hudfill.png";
wrap = "0";I haven't finished the save and load functions. I would like to get the rest working first (but any help and advice on those will be happily accepted!).
Brian
About the author
#2
03/25/2008 (1:47 pm)
And here are my functions://----------------------------------------------------------------------------
// Enter Programming Hud
//----------------------------------------------------------------------------
function ProgramHud::open(%this)
{
%offset = 6;
if(%this.isVisible())
return;
Canvas.pushDialog(%this);
%this.setVisible(true);
deactivateKeyboard();
ML_Code_Text.makeFirstResponder(true);
}
//------------------------------------------------------------------------------
function ProgramHud::close(%this)
{
if(!%this.isVisible())
return;
Canvas.popDialog(%this);
%this.setVisible(false);
if ( $enableDirectInput )
activateKeyboard();
ML_Code_Text.makeFirstResponder(false);
}
function ProgramHud::toggleState(%this)
{
if(%this.isVisible())
%this.close();
else
%this.open();
}
function ProgramHud::onSleep(%this)
{
activateKeyboard();
}
function ProgramHud::onWake(%this)
{
deactivateKeyboard();
}
function ProgramHud::onEscape(%this)
{
ProgramHud.deact();
}
function ProgramHud::deact(%this)
{
activateKeyboard();
ML_Code_Text.makeFirstResponder(false);
}
function toggleProgramHud(%make)
{
if(%make)
{
ProgramHud.toggleState();
}
}
#3
None of the buttons were working. I was getting a parse error everytime I clicked a button. Turns out I left the ; off the end of the command in the gui (need one inside the quotation marks and outside!)
I have updated the code above so that it is correct.
03/27/2008 (6:43 pm)
Well, here is a solution for those who come behind me (and no, I haven't gotten any help on this part):None of the buttons were working. I was getting a parse error everytime I clicked a button. Turns out I left the ; off the end of the command in the gui (need one inside the quotation marks and outside!)
I have updated the code above so that it is correct.
#4
It will find these errors for you.
03/27/2008 (10:54 pm)
This is why precompiling with Torision is great.It will find these errors for you.
#5
03/28/2008 (6:25 am)
That is what is so weird.. I did precompile with Torision. It didn't catch these errors!
Torque Owner B. Burton
new GuiTextEditCtrl(CodeName) { canSaveDynamicFields = "0"; Profile = "GuiDefaultProfile"; HorizSizing = "right"; VertSizing = "bottom"; position = "0 0"; Extent = "150 30"; MinExtent = "8 8"; canSave = "1"; Visible = "1"; AltCommand = "$ThisControl.eval();"; hovertime = "1000"; text = "NewBot"; maxLength = "120"; escapeCommand = "ProgramHud.onEscape();"; historySize = "5"; password = "0"; tabComplete = "0"; sinkAllKeyEvents = "0"; password = "0"; passwordMask = "*"; }; }; new GuiButtonCtrl(NewCode) { canSaveDynamicFields = "0"; Profile = "GuiButtonProfile"; HorizSizing = "right"; VertSizing = "bottom"; position = "265 295"; Extent = "90 30"; MinExtent = "8 2"; canSave = "1"; Visible = "1"; Command = "ProgramHud.New();"; hovertime = "1000"; text = "New"; groupNum = "-1"; buttonType = "PushButton"; }; new GuiButtonCtrl(LoadCode) { canSaveDynamicFields = "0"; Profile = "GuiButtonProfile"; HorizSizing = "right"; VertSizing = "bottom"; position = "385 295"; Extent = "90 30"; MinExtent = "8 2"; canSave = "1"; Visible = "1"; Command = "Load_Code();"; hovertime = "1000"; text = "Load"; groupNum = "-1"; buttonType = "PushButton"; }; new GuiButtonCtrl(SaveCode) { canSaveDynamicFields = "0"; Profile = "GuiButtonProfile"; HorizSizing = "right"; VertSizing = "bottom"; position = "505 295"; Extent = "90 30"; MinExtent = "8 2"; canSave = "1"; Visible = "1"; Command = "Save_Code();"; hovertime = "1000"; text = "Save"; groupNum = "-1"; buttonType = "PushButton"; }; new GuiButtonCtrl(CompileCode) { canSaveDynamicFields = "0"; Profile = "GuiButtonProfile"; HorizSizing = "right"; VertSizing = "bottom"; position = "625 295"; Extent = "90 30"; MinExtent = "8 2"; canSave = "1"; Visible = "1"; Command = "Compile_Code();"; hovertime = "1000"; text = "Compile"; groupNum = "-1"; buttonType = "PushButton"; }; new GuiButtonCtrl(Battle) { canSaveDynamicFields = "0"; internalName = "Battle"; Profile = "GuiButtonProfile"; HorizSizing = "right"; VertSizing = "bottom"; position = "745 295"; Extent = "90 30"; MinExtent = "8 2"; canSave = "1"; Visible = "1"; Command = "Battle();"; hovertime = "1000"; text = "Battle!"; groupNum = "-1"; buttonType = "PushButton"; }; new GuiButtonCtrl(Closer) { canSaveDynamicFields = "0"; internalName = "Battle"; Profile = "GuiButtonProfile"; HorizSizing = "right"; VertSizing = "bottom"; position = "865 295"; Extent = "90 30"; MinExtent = "8 2"; canSave = "1"; Visible = "1"; Command = "ProgramHud.close();"; hovertime = "1000"; text = "Close"; groupNum = "-1"; buttonType = "PushButton"; }; new GuiCheckBoxCtrl() { canSaveDynamicFields = "0"; Profile = "GuiCheckBoxProfile"; HorizSizing = "right"; VertSizing = "bottom"; position = "78 318"; Extent = "140 30"; MinExtent = "8 2"; canSave = "1"; Visible = "1"; Variable = "$Pref::Player::Ready"; hovertime = "1000"; text = "Ready to Battle?"; groupNum = "-1"; buttonType = "ToggleButton"; useInactiveState = "0"; }; }; //--- OBJECT WRITE END ---