GuiTextEditControl getvalue/setvalue in TGE 1.52
by Thomas Huehn · in Torque Game Engine · 01/15/2008 (3:10 am) · 0 replies
I noticed, that the messagehud edit setvalue("") have no effect in TGE 1.52.
After some digging I found out that the stringbuffer stores an UTF16 and UTF8 value.
When using MessageHud_Edit.setvalue(""); it calles void StringBuffer::set(const UTF8 *in) clear the mBuffer but mBuffer8 is still filled up with the last text so echo(MessageHud_Edit.getvalue("")); returns the last content.
To fix it I added an mDirty8=true :
Now it works again :)
After some digging I found out that the stringbuffer stores an UTF16 and UTF8 value.
When using MessageHud_Edit.setvalue(""); it calles void StringBuffer::set(const UTF8 *in) clear the mBuffer but mBuffer8 is still filled up with the last text so echo(MessageHud_Edit.getvalue("")); returns the last content.
To fix it I added an mDirty8=true :
void StringBuffer::set(const UTF8 *in)
{
incRequestCount8();
// Convert and store. Note that a UTF16 version of the string cannot be longer.
FrameTemp<UTF16> tmpBuff(dStrlen(in)+1);
if(!in || in[0] == 0 || !convertUTF8toUTF16(in, tmpBuff, dStrlen(in)+1))
{
// Easy out, it's a blank string, or a bad string.
mBuffer.clear();
mBuffer.push_back(0);
[b]
//XXTH mbuffer8 would not be cleared !!!
mDirty8 = true;
[/b]
AssertFatal(mBuffer.last() == 0, "StringBuffer::set UTF8 - not a null terminated string!");
return;
}
// Otherwise, we've a copy to do. (This might not be strictly necessary.)
mBuffer.setSize(dStrlen(tmpBuff)+1);
dMemcpy(mBuffer.address(), tmpBuff, sizeof(UTF16) * mBuffer.size());
mBuffer.compact();
AssertFatal(mBuffer.last() == 0, "StringBuffer::set UTF8 - not a null terminated string!");
mDirty8 = true;
}Now it works again :)
About the author
Contact: torque [AT] ohmtal [DOT] com