Page 1 of 1

Bug in CEGUI::Editbox::onCharacter() function

Posted: Thu Aug 10, 2006 20:42
by nate
forgive me if this is known or intended

it seems as though this function should not handle &e when the if() statement fails.

simply moving the statement
e.handled = true;
inside the preceding } should fix this issue.


thanks!


Code: Select all

void Editbox::onCharacter(KeyEventArgs& e)
{
   // base class processing
   Window::onCharacter(e);

   // only need to take notice if we have focus
   if (hasInputFocus() && getFont()->isCodepointAvailable(e.codepoint) && !isReadOnly())
   {
      // backup current text
      String tmp(d_text);
      tmp.erase(getSelectionStartIndex(), getSelectionLength());

      // if there is room
      if (tmp.length() < d_maxTextLen)
      {
         tmp.insert(getSelectionStartIndex(), 1, e.codepoint);

         if (isStringValid(tmp))
         {
            // erase selection using mode that does not modify d_text (we just want to update state)
            eraseSelectedText(false);

                // advance carat (done first so we can "do stuff" in event handlers!)
                d_caratPos++;

                // set text to the newly modified string
            setText(tmp);
         }
         else
         {
            // Trigger invalid modification attempted event.
            WindowEventArgs args(this);
            onInvalidEntryAttempted(args);
         }

      }
      else
      {
         // Trigger text box full event
         WindowEventArgs args(this);
         onEditboxFullEvent(args);
      }

   }

   e.handled = true;
}




i have a readonly Combobox, but as soon as something is selected from the dropdown, injectChar() begins returning true; claiming that my event is being handled
however, this should not be the case, as the combobox is readonly

processed |= CEGUI::System::getSingleton().injectChar( getKeyChar( rEvent.keyCode, modifiers ) );

Posted: Fri Aug 11, 2006 08:17
by CrazyEddie
Hi nate,

You didn't say which version of the library you're using :)

FYI, we have changed this behaviour for the upcoming 0.5.0 RC2 release, and it will only mark a character event as handled when that character is successfully added to the text string.

CE.

Posted: Fri Aug 11, 2006 14:45
by nate
!
you're right. i appologize.
i'm using an older version then.. 0.4.1

i'll have to check out the update. i'll be looking forward to it.
thanks CE! =)