[SOLVED] CEGUI 0.7.1 Editbox Characters not appearing

For help with general CEGUI usage:
- Questions about the usage of CEGUI and its features, if not explained in the documentation.
- Problems with the CMAKE configuration or problems occuring during the build process/compilation.
- Errors or unexpected behaviour.

Moderators: CEGUI MVP, CEGUI Team

User avatar
Van
Just can't stay away
Just can't stay away
Posts: 225
Joined: Fri Jan 21, 2005 20:29
Contact:

[SOLVED] CEGUI 0.7.1 Editbox Characters not appearing

Postby Van » Wed Oct 28, 2009 01:02

CEGUI 0.7.1 SVN 0.7 branch
Ogre 1.6.4 SVN trunk
MSVS 9.0+

Injected types characters are not appearing in Editboxes however BACKSPACE and ENTER and RETURN are being honored. IT worked fine in CEGUI 0.6.x.

We use OIS just as the examples do. Here is our code:

Code: Select all

   // Inject event into the CEGUI system.
   mConsumed = mCEGUISystem->injectKeyDown( ke.key );
   mConsumed = mCEGUISystem->injectChar( ke.text );


The window (Editbox) has two subscriptions:

Code: Select all

   mLEB[ LEB_ACCOUNT_PASS ]->subscribeEvent( CEGUI::Editbox::EventCharacterKey, CEGUI::Event::Subscriber( &clsGUILogin::event_LEB_ACCOUNT_CharacterKey, this ) );
   mLEB[ LEB_ACCOUNT_PASS ]->subscribeEvent( CEGUI::Editbox::EventTextAccepted, CEGUI::Event::Subscriber( &clsGUILogin::event_LEB_ACCOUNT_PASS_TextAccepted, this ) );


The these events ARE being fired when the keys are pressed therefore we know the injection event is working. We don't know why the characters are NOT appearing in the text boxes.

Any ideas why CEGUI is not honoring typed characters?
Last edited by Van on Mon Nov 02, 2009 23:32, edited 3 times in total.

User avatar
Van
Just can't stay away
Just can't stay away
Posts: 225
Joined: Fri Jan 21, 2005 20:29
Contact:

Re: CEGUI 0.7.1 Characters not appearing

Postby Van » Wed Oct 28, 2009 03:32

OK. That's not right at all:

When we REMOVE the two events from the CEGUI::Editbox, the typed characters appear. However, when we subscribe to events to the CEGUI::Editbox the type characters do not appear.

User avatar
Van
Just can't stay away
Just can't stay away
Posts: 225
Joined: Fri Jan 21, 2005 20:29
Contact:

Re: CEGUI 0.7.1 Characters not appearing

Postby Van » Wed Oct 28, 2009 03:38

There is something NOT correct with the CEGUI::Editbox::EventCharacterKey event. Any CEGUI::Editbox subscribed to this event will not accept text input.

The CEGUI::Editbox::EventTextAccepted works fine.

User avatar
scriptkid
Home away from home
Home away from home
Posts: 1178
Joined: Wed Jan 12, 2005 12:06
Location: The Hague, The Netherlands
Contact:

Re: [BUG] CEGUI 0.7.1 Characters not appearing

Postby scriptkid » Wed Oct 28, 2009 15:56

Hi,

Maybe it's related to this thread?:
viewtopic.php?f=10&t=4352&p=20222&hilit=editbox#p20222

The PO mentiones another event, but it could have to do with the value (true/false) you return from your handlers.

Please let me know if that changes anything.
Check out my released snake game using Cegui!

User avatar
Van
Just can't stay away
Just can't stay away
Posts: 225
Joined: Fri Jan 21, 2005 20:29
Contact:

Re: [BUG] CEGUI 0.7.1 Characters not appearing

Postby Van » Wed Oct 28, 2009 20:23

I don't think that is the same problem. Here is our code:

This does NOT work.

Code: Select all

   mLEB[ LEB_ACCOUNT_NAME ] = static_cast<CEGUI::Editbox*>(mWinMgr.getWindow( "Login/R/EditBox/Account/Name" ) );
   mLEB[ LEB_ACCOUNT_NAME ]->setMaxTextLength( SUBSCRIBER_ACCOUNT_NAME_SIZE );
   mLEB[ LEB_ACCOUNT_NAME ]->subscribeEvent( CEGUI::Editbox::EventCharacterKey, CEGUI::Event::Subscriber( &clsGUILogin::event_LEB_ACCOUNT_CharacterKey, this ) );
   mLEB[ LEB_ACCOUNT_NAME ]->subscribeEvent( CEGUI::Editbox::EventTextAccepted, CEGUI::Event::Subscriber( &clsGUILogin::event_LEB_ACCOUNT_NAME_TextAccepted, this ) );


This does NOT work.

Code: Select all

   mLEB[ LEB_ACCOUNT_NAME ] = static_cast<CEGUI::Editbox*>(mWinMgr.getWindow( "Login/R/EditBox/Account/Name" ) );
   mLEB[ LEB_ACCOUNT_NAME ]->setMaxTextLength( SUBSCRIBER_ACCOUNT_NAME_SIZE );
   mLEB[ LEB_ACCOUNT_NAME ]->subscribeEvent( CEGUI::Editbox::EventCharacterKey, CEGUI::Event::Subscriber( &clsGUILogin::event_LEB_ACCOUNT_CharacterKey, this ) );
   // mLEB[ LEB_ACCOUNT_NAME ]->subscribeEvent( CEGUI::Editbox::EventTextAccepted, CEGUI::Event::Subscriber( &clsGUILogin::event_LEB_ACCOUNT_NAME_TextAccepted, this ) );


This DOES work.

Code: Select all

   mLEB[ LEB_ACCOUNT_NAME ] = static_cast<CEGUI::Editbox*>(mWinMgr.getWindow( "Login/R/EditBox/Account/Name" ) );
   mLEB[ LEB_ACCOUNT_NAME ]->setMaxTextLength( SUBSCRIBER_ACCOUNT_NAME_SIZE );
   // mLEB[ LEB_ACCOUNT_NAME ]->subscribeEvent( CEGUI::Editbox::EventCharacterKey, CEGUI::Event::Subscriber( &clsGUILogin::event_LEB_ACCOUNT_CharacterKey, this ) );
   mLEB[ LEB_ACCOUNT_NAME ]->subscribeEvent( CEGUI::Editbox::EventTextAccepted, CEGUI::Event::Subscriber( &clsGUILogin::event_LEB_ACCOUNT_NAME_TextAccepted, this ) );


Both of our events always return TRUE. If you will notice in the second code box example, only event_LEB_ACCOUNT_CharacterKey() has been subscribed too and it still does not work. I think there is something wrong with the CEGUI::EventCharacterKey event in the library code. We don't modify the CEGUI SDK library. It's just out-of-the-box CEGUI.

Jamarr
CEGUI MVP
CEGUI MVP
Posts: 812
Joined: Tue Jun 03, 2008 23:59
Location: USA

Re: [BUG] CEGUI 0.7.1 Characters not appearing

Postby Jamarr » Thu Oct 29, 2009 17:09

It certainly sounds like what Scriptkid pointed out. Can you post the clsGUILogin::event_LEB_ACCOUNT_CharacterKey function?

In any case, have you tried debugging/stepping into CEGUI to see exactly what is causing this to occur?
If somebody helps you by replying to your thread, upvote him/her as a thanks! Make sure to include your CEGUI.log and everything you tried when posting! And remember that we are not magicians!

User avatar
Van
Just can't stay away
Just can't stay away
Posts: 225
Joined: Fri Jan 21, 2005 20:29
Contact:

Re: [BUG] CEGUI 0.7.1 Characters not appearing

Postby Van » Thu Oct 29, 2009 20:05

Jamarr wrote:It certainly sounds like what Scriptkid pointed out. Can you post the clsGUILogin::event_LEB_ACCOUNT_CharacterKey function?


Here are both event callback functions:

Code: Select all

bool clsGUILogin::event_LEB_ACCOUNT_NAME_TextAccepted(const CEGUI::EventArgs& e)
{
   // Validation
   if ( mLEB[ LEB_ACCOUNT_NAME ]->getText().empty() )
      mLDW[ LDW_STATUSBAR ]->setText( "Account may not be blank." );

   setInputState();

   return true;
} // event_LEB_ACCOUNT_NAME_TextAccepted


bool clsGUILogin::event_LEB_ACCOUNT_CharacterKey(const CEGUI::EventArgs& e)
{
   const CEGUI::KeyEventArgs& mKEA = static_cast<const CEGUI::KeyEventArgs&>( e );
   const CEGUI::WindowEventArgs& mWEA = static_cast<const CEGUI::WindowEventArgs&>( e );
   if ( !mWEA.window ) return true;

   // Quick Backspace ( Shift + Backspace )
   if ( ( mKEA.sysKeys & CEGUI::SystemKey::Shift ) && mKEA.scancode == CEGUI::Key::Backspace )
      mWEA.window->setText( "" );

   return true;
} // event_LEB_ACCOUNT_CharacterKey


This is just a simple event however we utilize CEGUI::Editbox::EventCharacterKey in many many places and they get more complex. This issue is a real show-stopper at the moment. Our application is virtually unusable until this issue is addressed.

Jamarr wrote:In any case, have you tried debugging/stepping into CEGUI to see exactly what is causing this to occur?

I'm really trying to avoid that as I don't have the time to study and learn the innards of CEGUI. I would prefer that one of the CEGUI project developers look into it (as they should) because they could quickly find and squash the issue.

Jamarr
CEGUI MVP
CEGUI MVP
Posts: 812
Joined: Tue Jun 03, 2008 23:59
Location: USA

Re: [BUG] CEGUI 0.7.1 Characters not appearing

Postby Jamarr » Thu Oct 29, 2009 20:47

Unfortunately CE is really the only active developer atm, and as you may not be aware he is now on haitus for at least a month. Scriptkid may be able to take a look at it, though I'm not sure how much time he has to dedicate to bug tracking.

You really should not need to know the ins-and-outs of CEGUI to be able to track down something like this. It sounds like it would be something relatively minor.
If somebody helps you by replying to your thread, upvote him/her as a thanks! Make sure to include your CEGUI.log and everything you tried when posting! And remember that we are not magicians!

User avatar
Van
Just can't stay away
Just can't stay away
Posts: 225
Joined: Fri Jan 21, 2005 20:29
Contact:

Re: [BUG] CEGUI 0.7.1 Characters not appearing

Postby Van » Thu Oct 29, 2009 21:32

Jamarr wrote:Unfortunately CE is really the only active developer atm, and as you may not be aware he is now on haitus for at least a month. Scriptkid may be able to take a look at it, though I'm not sure how much time he has to dedicate to bug tracking.


Thanks for the heads up.

Jamarr wrote:You really should not need to know the ins-and-outs of CEGUI to be able to track down something like this. It sounds like it would be something relatively minor.

Yea, that's what they all say. :roll:

User avatar
Van
Just can't stay away
Just can't stay away
Posts: 225
Joined: Fri Jan 21, 2005 20:29
Contact:

Re: [BUG] CEGUI 0.7.1 Characters not appearing

Postby Van » Sun Nov 01, 2009 19:40

Today I started looking into this problem and I stumbled onto this comment in the Editbox::onCharacter()

Editbox::onCharacter() wrote: // NB: We are not calling the base class handler here because it propogates
// inputs back up the window hierarchy, whereas, as a consumer of key
// events, we want such propogation to cease with us regardless of whether
// we actually handle the event.


I think that is our problem. The event should NOT stop the propagation of keystrokes. Does anyone know the reason for this?

User avatar
Van
Just can't stay away
Just can't stay away
Posts: 225
Joined: Fri Jan 21, 2005 20:29
Contact:

Re: [BUG] CEGUI 0.7.1 Editbox Characters not appearing

Postby Van » Sun Nov 01, 2009 23:09

The CEGUI::Spinner::EventKeyUp() has the same problem because it uses CEGUI::Editbox.

User avatar
Van
Just can't stay away
Just can't stay away
Posts: 225
Joined: Fri Jan 21, 2005 20:29
Contact:

Re: [BUG] CEGUI 0.7.1 Editbox Characters not appearing

Postby Van » Sun Nov 01, 2009 23:40

EDIT: Removed text
Last edited by Van on Tue Nov 03, 2009 00:17, edited 1 time in total.

User avatar
Van
Just can't stay away
Just can't stay away
Posts: 225
Joined: Fri Jan 21, 2005 20:29
Contact:

Re: [SOLVED] CEGUI 0.7.1 Editbox Characters not appearing

Postby Van » Mon Nov 02, 2009 23:31

SOLVED

After tracing and debugging I think I found out whats going on. For certain events (why some work and some do not depends on the elements implementation). For anything using the CEGUI::Editbox, you must return FALSE from your event callback function WHEN your event does NOT handle the input. This is so that CEGUI will properly continue to handle the event and insert the character.

IMPROPER USAGE

Code: Select all


...
subscribeEvent( "TextDemo/editName", Editbox::EventCharacterKey, Event::Subscriber( &TextDemo::eventCharacterKeyHandler, this ) );
...

bool TextDemo::eventCharacterKeyHandler(const CEGUI::EventArgs& e)
{
   const CEGUI::KeyEventArgs& mKEA = static_cast<const CEGUI::KeyEventArgs&>( e );
   const CEGUI::WindowEventArgs& mWEA = static_cast<const CEGUI::WindowEventArgs&>( e );
   if ( !mWEA.window ) return false;

   // Quick Backspace ( Shift + Backspace )
   if ( ( mKEA.sysKeys & CEGUI::SystemKey::Shift ) && mKEA.scancode == CEGUI::Key::Backspace )
   {
      mWEA.window->setText( "" );
      // event was handled
      return true;
   }

   // event was not handled
   return true;  // <<<<<<<<<<<<<<<<<<<<<<< INCORRECT, CEGUI will no longer process the input
} // eventCharacterKeyHandler



PROPER USAGE

Code: Select all

...
subscribeEvent( "TextDemo/editName", Editbox::EventCharacterKey, Event::Subscriber( &TextDemo::eventCharacterKeyHandler, this ) );
...

bool TextDemo::eventCharacterKeyHandler(const CEGUI::EventArgs& e)
{
   const CEGUI::KeyEventArgs& mKEA = static_cast<const CEGUI::KeyEventArgs&>( e );
   const CEGUI::WindowEventArgs& mWEA = static_cast<const CEGUI::WindowEventArgs&>( e );
   if ( !mWEA.window ) return false;

   // Quick Backspace ( Shift + Backspace )
   if ( ( mKEA.sysKeys & CEGUI::SystemKey::Shift ) && mKEA.scancode == CEGUI::Key::Backspace )
   {
      mWEA.window->setText( "" );
      // event was handled
      return true;
   }

   // event was not handled
   return false;  // <<<<<<<<<<<<<<<<<<<<<<< CORRECT, CEGUI will continue to process the input
} // eventCharacterKeyHandler


This is a big change from 0.6.x. This is mentioned in the porting documentation but isn't made very clear as the demo's don't ever demonstrate this particular implementation by CEGUI::Editbox(). The DEMO's always return TRUE whether the event callback actually did something or not. There seems to be a lack of continuity.

Jamarr
CEGUI MVP
CEGUI MVP
Posts: 812
Joined: Tue Jun 03, 2008 23:59
Location: USA

Re: [SOLVED] CEGUI 0.7.1 Editbox Characters not appearing

Postby Jamarr » Tue Nov 03, 2009 20:27

Yes. Sorry I thought this was obvious and you where already doing this. I even asked to see your function and I never even looked at it. Nor did it occur to me when you posted that your functions where always returning true. I must have been really out of it that day lol. I'm glad you got it worked out ;)
If somebody helps you by replying to your thread, upvote him/her as a thanks! Make sure to include your CEGUI.log and everything you tried when posting! And remember that we are not magicians!


Return to “Help”

Who is online

Users browsing this forum: No registered users and 15 guests