Game Development Community

GuiTextEditCtrl no $ThisControl in validate command

by Tom Spilman · in Torque Game Engine · 06/01/2006 (11:07 pm) · 1 replies

The current implementation of GuiTextEditCtrl::onLoseFirstResponder() performs a callback used to validate the contents of the control, prompt the user to fix it, fix it automatically, whatever. The problem is unlike for the mConsoleCommand and mAltConsoleCommand it doesn't set the $ThisControl value before it executes.

A corrected version of onLoseFirstResponder()...

void GuiTextEditCtrl::onLoseFirstResponder()
{
   Platform::disableKeyboardTranslation();

   //first, update the history
   updateHistory( &mTextBuffer, true );

   //execute the validate command
   if ( mValidateCommand[0] )
   {
      char buf[16];
      dSprintf( buf, sizeof( buf ), "%d", getId() );
      Con::setVariable( "$ThisControl", buf );
      Con::evaluate( mValidateCommand, false );
   }

   // Redraw the control:
   setUpdate();
}

- Tom

About the author

Tom is a programmer and co-owner of Sickhead Games, LLC.