Game Development Community

Problem with GuiTextEditCtrl - help please

by Brian Carter · in Torque Game Builder · 03/12/2008 (8:09 pm) · 6 replies

I have my first GUI working fine except for one small problem. If I run the GUI screen in the default resolution (800x600) and then type text in the field it doesnt show - it does show the cursor moving with the text entry, but its almost as though the text is either invisible, or so small that there is nothing there. However, if I change the options so that the GUI shows fullscreen at 2560x1600 then the control works fine, abeit with a slightly smaller font than I would like.

I've tried creating a new profile derived from GuiTextEditProfile and setting various font sizes ranging from 10 through 36 .. and the same thing happens regardless of the font size I use (and yes I did change the profile in the GuiTextEditControl() to match the new one. I even increased the Extent height - again, no difference.

This is the default control as it appears in my GUI file -

new GuiTextEditCtrl( CharacterName ) {
canSaveDynamicFields = "0";
isContainer = "0";
Profile = "GuiTextEditProfile";
HorizSizing = "relative";
VertSizing = "relative";
Position = "280 277";
Extent = "158 18";
MinExtent = "8 2";
canSave = "1";
Visible = "1";
hovertime = "1000";
maxLength = "1024";
historySize = "0";
password = "0";
tabComplete = "0";
sinkAllKeyEvents = "0";
password = "0";
passwordMask = "*";
};

I'm at a loss, all I want to do is allow my player to enter in their character name, nothing fancy.

#1
03/14/2008 (6:01 am)
Nobody else having a problem with GuiTextEditCtrl ?? How are you getting the font to scale with a screen size? I can't get this to work and it seems like such a simple thing that I shouldn't be having any problems with this.
#2
03/14/2008 (7:44 am)
Have you tried setting the MinExtent to a larger value? Perhaps set it to also equal "158 18" so that it maintains a minimum size (as per your base extent size from above)?

You might also pull up the console and type:

CharacterName.dump(); // see all of the properties

or just:

echo(CharacterName.Extent); // or whatever other property you are interested in reviewing

That should help you "see" what is really going on with the control, giving you something to go on from there.
#3
03/14/2008 (8:12 am)
I will give that a try thanks Derelict. I tried adjusting Extent but didnt try MinExtent.
#4
03/14/2008 (10:35 am)
OK that solved part of the problem, the MinExtent now allows the text to be show in 800x600 mode; however, when I switch up to 2560x1600 the text box increases in size relative to the resolution change, but the font remains at 14 point so it now looks tiny.

Are there functions that you know of that allow for dynamically sizing the font of the edit box to match the screen resolutions? Or do I need to script that functionality in? How do other people deal with changing screen resolutions and font sizes in text edit controls?
#5
03/14/2008 (11:22 am)
I suspect that you would want to modify the profile based on the resolution the user has selected (or you have set it to be).

You might create different profiles, lets say "ProfileA", "ProfileB", and "ProfileC" and then, in code, when the user changes resolution you might store the resolution type (Res_HIGH, Res_MEDIUM, Res_LOW) in a global variable called $curResolutionType:

if($curResolutionType $= "RES_HIGH")
     CharacterName.Profile = "ProfileA";
else if ($curResolutionType $= "RES_MEDIUM")
     CharacterName.Profile = "ProfileB";
else if ($curResolutionType $= "RES_LOW");
     CharacterName.Profile = "ProfileC";

Something like that could work, I suspect, though I haven't tried dynamically changing profiles as of yet.

Honestly, an answer to your question is a little more involved than what I've mentioned above, but that provides sort of the "jist" as to how you might approach it. Some methods simply require more coding and design than others. :)
#6
03/14/2008 (11:39 am)
Kinda what I figured. It's a shame there is no code built into the edit control to allow for a dynamically sizable font - maybe this is something I will look at and if I get it to work then post it for others to use. I would just be suprised if nobody else has run into this problem before, especially with all of the MMO's that are being flaunted as being in development.

Anyhoo, thanks for your input, you at least managed to fix one of my problems :) I dont know how I missed that MinExtent property - oh well, live and learn.