TGE1.4: guiTextEditCtrl bug&fix.
by Chris Shark · in Torque Game Engine · 11/26/2005 (11:42 am) · 27 replies
Hello
I found bug in TGE1.4 / guiTextEditCtrl .
When i click [Password] check in guiTextEditCtrl, my torque-app is suspended.
here is my fixes:
In file: gui/guiTextEditCtrl.cc proc: void GuiTextEditCtrl::drawText(...)
Ln 968:
Now is OK (and not suspended)!
But i still dont see "*" symbol with password-checked in texteditctrl.
and now fix:
Ln 1039:
Ln 1125:
Ln 1145:
Cya.
I found bug in TGE1.4 / guiTextEditCtrl .
When i click [Password] check in guiTextEditCtrl, my torque-app is suspended.
here is my fixes:
In file: gui/guiTextEditCtrl.cc proc: void GuiTextEditCtrl::drawText(...)
Ln 968:
...
// Apply password masking (make the masking char optional perhaps?)
if(mPasswordText)
{
[b]//@SHARKK:@2:earlier here--> for(U32 i = 0; i<mTextBuffer.length()-1; i++)[/b]
for(U32 i = 0; i<mTextBuffer.length(); i++)
textBuffer.append(StringBuffer(mPasswordMask));
}
else
...Now is OK (and not suspended)!
But i still dont see "*" symbol with password-checked in texteditctrl.
and now fix:
Ln 1039:
// calculate the cursor
if ( isFocused )
{
// Where in the string are we?
[b]//@SHARKK:@2: earlier here: mTextBuffer.substring(.)....[/b]
StringBuffer preCursor = textBuffer.substring(0, mCursorPos);
S32 cursorOffset=0, charWidth=0;
[b]//@SHARKK:@2: earlier here: mTextBuffer.getChar(.)....[/b]
UTF16 tempChar = textBuffer.getChar(mCursorPos);Ln 1125:
//draw the hilighted portion
if ( mBlockEnd > 0 )
{
[b]//@SHARKK:@2: I think should have textBuffer not mTextBuffer.substring(.)....[/b]
StringBuffer highlightBuff = textBuffer.substring(mBlockStart, mBlockEnd-mBlockStart);Ln 1145:
//draw the portion after the highlite
if(mBlockEnd < mTextBuffer.length())
{
[b]//@SHARKK:@2: I think should have textBuffer not mTextBuffer.substring(.)....[/b]
StringBuffer finalBuff = textBuffer.substring(mBlockEnd, mTextBuffer.length() - mBlockEnd);
FrameTemp<UTF8> finalTemp(finalBuff.length()*3 + 1);Cya.
#2
I was seeing a problem where the joinServerGui and startMissionGui was not properly filling in the players name from the prefs.cs. Specifically $pref::player::name. What would happen is that the edit ctrl would clear every time it was added thus setting the $pref::player:name to null. This never was a problem in 1.3 so i did a winMerge on the two files.
The only thing i could see obvious is that the new 1.4's onAdd member has a call to setText(mText); Where mText is always set to a blank string. So I commented out the call to setText(mText); and it works now and doesn't clear the $pref::player::name. The only weird thing is that it seems the cursor position is set to one less than the string length and not at the very end.
Any suggestions or comments on this?
Thanks Chris and Ben.
11/26/2005 (1:40 pm)
I think i have found another problem with the guiTextEditCtrl......I was seeing a problem where the joinServerGui and startMissionGui was not properly filling in the players name from the prefs.cs. Specifically $pref::player::name. What would happen is that the edit ctrl would clear every time it was added thus setting the $pref::player:name to null. This never was a problem in 1.3 so i did a winMerge on the two files.
The only thing i could see obvious is that the new 1.4's onAdd member has a call to setText(mText); Where mText is always set to a blank string. So I commented out the call to setText(mText); and it works now and doesn't clear the $pref::player::name. The only weird thing is that it seems the cursor position is set to one less than the string length and not at the very end.
Any suggestions or comments on this?
Thanks Chris and Ben.
#3
11/29/2005 (9:11 am)
Hey ben can you comment on this last thing if you get a chance? I think this will be a problem for whenever anybody uses a guiTextEditCtrl with a variable in 1.4 since it will always clear it when its added.
#4
11/29/2005 (11:03 am)
Hmm, that also looks like a good fix. The issue I filed just links to this thread, so when we resolve the issue we'll be looking at all the fixes/problems in here.
#5
11/29/2005 (12:19 pm)
Sounds good.
#6
Put back the setText call and change the setText method as follows which fixes everything.
12/07/2005 (2:31 pm)
If you comment out the setText command in the onAdd method, then the World editor develops bugs. e.g. try adding a trigger and note that the polyhedron values dont get displayed in the textedit control.Put back the setText call and change the setText method as follows which fixes everything.
void GuiTextEditCtrl::setText( const char *txt )
{
if(txt && txt[0] != 0){
Parent::setText( txt );
mTextBuffer.set( txt );
}
else
mTextBuffer.set( "" );
mCursorPos = mTextBuffer.length();
}
#7
12/14/2005 (3:18 pm)
About the player name problem - did you try porting some 1.3 code to 1.4. They seemed to change the textbox - it's being cleared when the client code is loaded. What you need to do is set the text of the name text box to the pref var. It'll fix it!
#8
12/14/2005 (5:10 pm)
This problem shows up in the starter.fps so no i didn't port.
#9
Does anyone have any ideas?
12/28/2005 (12:33 pm)
I made Duncan's change to the setText function, but that didn't really solve the problem. It prevented the variable from being overwritten by a blank string, but the actual string from the variable still didn't show up. So, I made a change of my own, and it sort of works. In the onAdd function I added this just before the final return:const char * var = getVariable();
if(var && var[0]!='[[62813b22ec54e]]')
{
setText(var);
}This causes the variable to be read in, but for some reason the string still doesn't display (I know that the variable is being read by stepping through in debug mode). The weird thing is, if I replace the setText(var) with setText("Foo"), the control actually does display "Foo", which then gets saved to the prefs file when the app is closed. I've stepped through both versions of the onAdd function, and the setText function behaves exactly the same with both the var and the string literal, so I guess some other function is somehow comparing the current string against the contents of the variable before anything is displayed. I just can't see where this is happening.Does anyone have any ideas?
#10
I am now getting a problem where the cursor appears just before the last character, but that could be my fault too.
EDIT -- I removed the -1 in GuiTextEditCtrl::setScriptValue() and that solved the cursor position problem. Everything seems OK now, but I guess time will tell whether or not it has created new problems.
12/28/2005 (1:27 pm)
Well, now I feel stupid. Duncan's fix does work on its own, I just made some mistakes in testing it. My change to onAdd is completely unneccessary.I am now getting a problem where the cursor appears just before the last character, but that could be my fault too.
EDIT -- I removed the -1 in GuiTextEditCtrl::setScriptValue() and that solved the cursor position problem. Everything seems OK now, but I guess time will tell whether or not it has created new problems.
#11
I've put all the fixes one by one (excluding Tony's "onAdd" ofcourse) and everything works just perfect. Thanks guys.
But (looks like there will be always "but's") I feel really uncomfortable when I trying selecting text by mouse in password boxes.
By now it "counts" size of actual text and your mouse selects text not right under your mouse pointer.
So I came up with the following small fix.
in same file (guiTextEditCtrl.cc) in S32 GuiTextEditCtrl::setCursorPos( const Point2I &offset ) I've changed the internal loop to look like this:
01/04/2006 (12:00 pm)
Nice fixes,I've put all the fixes one by one (excluding Tony's "onAdd" ofcourse) and everything works just perfect. Thanks guys.
But (looks like there will be always "but's") I feel really uncomfortable when I trying selecting text by mouse in password boxes.
By now it "counts" size of actual text and your mouse selects text not right under your mouse pointer.
So I came up with the following small fix.
in same file (guiTextEditCtrl.cc) in S32 GuiTextEditCtrl::setCursorPos( const Point2I &offset ) I've changed the internal loop to look like this:
for(count=0; count<mTextBuffer.length(); count++)
{
[b]//bank060104 "*" password textselect mod
// Apply password masking char size
if(mPasswordText)
charLength += mFont->getCharXIncrement( mPasswordMask[0] );
else
// Or else just count the actual size.[/b]
charLength += mFont->getCharXIncrement( mTextBuffer.getChar(count) );
if ( charLength > curX )
break;
}And now everything(?) really perfect.
#12
01/05/2006 (7:20 am)
Just wanted to check and see if this bug fix is going to be put into CVS anytime soon?
#13
01/08/2006 (2:10 am)
#1083.
#14
01/23/2006 (1:07 am)
Nice fix .. i must of crashed about 6 times trying to get that dumb password checkbox to work
#15
02/08/2006 (3:40 pm)
Thanks for the fix.
#16
To fix, go to GuiTextEditCtrl::onKeyDown method and find the case KEY_V: section and add
02/11/2006 (10:45 pm)
Yet another small problem. When pasting text into the edit box, (like an unlock key) the console variable does not get updated.To fix, go to GuiTextEditCtrl::onKeyDown method and find the case KEY_V: section and add
// Execute the console command!
execConsoleCallback();just before the return true at the end of that section
#17
Do you know if critical fixes like this are being verified as "needed"/"unnecessary"/"done already" for TSE, or is that something TSE owners are going to need to do on their own?
Along those same lines, is there a wishlist or voting booth where TSE owners can vote for community impovements to TGE that they'd really like to see pre-bult into TSE. I'm thinking of the really popular adds like Advanced Camera, ODBC Connectivity, Mouse Events to GUI Controls, Swimming, etc...
Thanks!
04/04/2006 (8:53 pm)
Ben,Do you know if critical fixes like this are being verified as "needed"/"unnecessary"/"done already" for TSE, or is that something TSE owners are going to need to do on their own?
Along those same lines, is there a wishlist or voting booth where TSE owners can vote for community impovements to TGE that they'd really like to see pre-bult into TSE. I'm thinking of the really popular adds like Advanced Camera, ODBC Connectivity, Mouse Events to GUI Controls, Swimming, etc...
Thanks!
#18
04/26/2006 (2:34 pm)
These fixes are not in the current TSE head version that I have. The fixes work perfectly in TSE.
#19
04/27/2006 (5:29 pm)
These fixes aren't even in 1.4 TGE release, I'm hoping it's in 1.42, since I don't wanna sort through all these little tweaks and worry about breaking stuff.
#20
I don't log in daily, sometimes not even weekly so an official email to notify us of the release would be nice and professional when its ready.
04/27/2006 (6:22 pm)
@Ben or other GG staff. As a convenience to the community, can you send out a global email to the community when 1.42 gets released. I don't log in daily, sometimes not even weekly so an official email to notify us of the release would be nice and professional when its ready.
Associate Kyle Carter