Caps Lock not working with GuiTextEditCtrl [With Fix]
by Harry Durnan · in Torque Game Builder · 06/09/2013 (8:50 am) · 0 replies
I know no more builds are getting cut for TBG, but I feel there may still be some merit in posting bug fixes for those of us still using it. I noticed this morning when doing some testing that Caps lock wasn't being respected by my GUITextEditCtrl's. I found a fix for this on the T3D forums and ported it into T2D.
In guicontrolsguiTextEditCtrl.cc
Starting around line 930 (It may be off a little from the core because I also added call backs for OnKeyDown):
Old:
New:
Oh, I also added windows.h as an include. It was recommended on the post I borrowed most of this fix from ( http://www.garagegames.com/community/forums/viewthread/130515 ).
In guicontrolsguiTextEditCtrl.cc
Starting around line 930 (It may be off a little from the core because I also added call backs for OnKeyDown):
Old:
if ( mFont->isValidChar( event.ascii ) )
{
// Get the character ready to add to a UTF8 string.
UTF16 convertedChar[2] = { event.ascii + modifier, 0 };
//see if it's a number field
if ( mProfile->mNumbersOnly )
{
if (event.ascii == '-')
{New:
if ( mFont->isValidChar( event.ascii ) )
{
// hack to handle Caps lock, because OMG it doesn't work...
bool caps = GetKeyState(20);
int modifier = 0;
if( caps && event.ascii>=97 && event.ascii<=122) { // If capslock on and character lowercase
modifier-=32; // Make lower case character upper case
} else if(caps && event.ascii>=65 && event.ascii<=90 && (event.modifier & SI_SHIFT)) { // If capslock on, character uppercase, and shift down
modifier=32; // Make upper case character lower case
}
//End added code
// Get the character ready to add to a UTF8 string.
UTF16 convertedChar[2] = { event.ascii + modifier, 0 };
//see if it's a number field
if ( mProfile->mNumbersOnly )
{
if (event.ascii == '-')
{Oh, I also added windows.h as an include. It was recommended on the post I borrowed most of this fix from ( http://www.garagegames.com/community/forums/viewthread/130515 ).
About the author
Author of It's A Wipe! (http://www.iawgame.com :)