Window::getCaptureWindow() returns NULL

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
cippyboy
Quite a regular
Quite a regular
Posts: 51
Joined: Wed Jul 30, 2008 13:23

Window::getCaptureWindow() returns NULL

Postby cippyboy » Mon Sep 07, 2009 12:12

Hi,

I'm trying to figure out if the user is in an editable window and typing stuff (so that it doesn't trigger key shortcuts) and I'm having a really bad time with this. When inside a MultiLineEditbox Window::getCaptureWindow() returns NULL, now why is that when I am clearly typing stuff in it ? I also tried EventInputCaptureGained/Lost only to see weird behaviour like receiving a lost message when I'm actually still inside it. What is the best way to detect if the keyboard is sending text to an edit box ?

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

Re: Window::getCaptureWindow() returns NULL

Postby CrazyEddie » Mon Sep 07, 2009 17:45

Go to the search box and type in: editbox key event

HTH

CE.

User avatar
cippyboy
Quite a regular
Quite a regular
Posts: 51
Joined: Wed Jul 30, 2008 13:23

Re: Window::getCaptureWindow() returns NULL

Postby cippyboy » Tue Sep 08, 2009 11:13

Thanks ! This piece of code is the solve (in case someone's reading through the post)

Code: Select all

CEGUI::Editbox* getActiveEditbox()
{
   using namespace CEGUI;

   Window* root = System::getSingleton().getGUISheet();
   
   if (root)
   {
      Window* activeChild = root->getActiveChild();
     
      if ((activeChild != 0) &&
         activeChild->testClassName("Editbox") &&
         static_cast<Editbox*>(activeChild)->hasInputFocus())
      {
         return static_cast<Editbox*>(activeChild);
      }
   }

   return 0;
}


It also works with multiline boxes by just editing the classes involved from Editbox to MultiLineEditbox.


Return to “Help”

Who is online

Users browsing this forum: No registered users and 5 guests