Cursor Position in guiMLTextEditCtrl
by Dave Young · in Torque Game Engine · 05/23/2008 (7:15 am) · 3 replies
A little annoyance I'm trying to fix: in the guiMLTextEditCtrl, the cursor position is not accurate:
1) If you click on a place where you would like the cursor to be
2) If you try to move the cursor with the arrow keys, where text is inserted does not match up with where the cursor is.
Before I begin swamping through the code for the control, has anyone addressed this yet?
1) If you click on a place where you would like the cursor to be
2) If you try to move the cursor with the arrow keys, where text is inserted does not match up with where the cursor is.
Before I begin swamping through the code for the control, has anyone addressed this yet?
#2
In GuiMLTextEditCtrl.cc (onKeyDown), change:
to:
and in GuiMLTextCtrl.cc (getCursorPositionAndColor), change:
to:
10/22/2010 (8:12 pm)
I've been annoyed by this for a while and finally had the day off so I decided to fix it. I thought about fixing some other issues with the control, but those proved to be more difficult so this only fixes the cursor's visual position (clicking with mouse or using arrow keys) and some minor copy/cut issues.In GuiMLTextEditCtrl.cc (onKeyDown), change:
if (mSelectionActive)
{
copyToClipboard(mSelectionStart, mSelectionEnd);
//if we're cutting, also delete the selection
if (event.keyCode == KEY_X)
{
mSelectionActive = false;
deleteChars(mSelectionStart, mSelectionEnd);
mCursorPosition = mSelectionStart;
}
else
mCursorPosition = mSelectionEnd + 1;
}
return true;to:
if (mSelectionActive)
{
copyToClipboard(mSelectionStart, mSelectionEnd+1);
//if we're cutting, also delete the selection
if (event.keyCode == KEY_X)
{
mSelectionActive = false;
deleteChars(mSelectionStart, mSelectionEnd+1);
mCursorPosition = mSelectionStart;
}
else
mCursorPosition = mSelectionEnd + 1;
}
return true;and in GuiMLTextCtrl.cc (getCursorPositionAndColor), change:
x += font->getStrNWidth(buff, mCursorPosition - awalk->textStart - 1);
to:
x += font->getStrNWidth(buff, mCursorPosition - awalk->textStart);
#3
11/09/2010 (6:28 pm)
Thanks @Bruno I guess I have the same problem like @Dave in some part of my code. I'll try to use it. Really thanks for your time.
Torque 3D Owner Peter Simard
Default Studio Name