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

Forum for general chit-chat or off-topic discussion.

Moderators: CEGUI MVP, CEGUI Team

nate
Just popping in
Just popping in
Posts: 2
Joined: Thu Aug 10, 2006 19:55
Location: San Diego, Ca
Contact:

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

Postby nate » Thu Aug 10, 2006 20:42

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 ) );

User avatar
CrazyEddie
CEGUI Project Lead
Posts: 6760
Joined: Wed Jan 12, 2005 12:06
Location: England
Contact:

Postby CrazyEddie » Fri Aug 11, 2006 08:17

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.

nate
Just popping in
Just popping in
Posts: 2
Joined: Thu Aug 10, 2006 19:55
Location: San Diego, Ca
Contact:

Postby nate » Fri Aug 11, 2006 14:45

!
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! =)


Return to “Offtopic Discussion”

Who is online

Users browsing this forum: No registered users and 11 guests