[Solved] Editboxes with OIS and Ogre3d

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

Arikaido
Just popping in
Just popping in
Posts: 4
Joined: Sat Apr 09, 2016 09:00

[Solved] Editboxes with OIS and Ogre3d

Postby Arikaido » Sat Apr 09, 2016 09:06

So I have been scouring the forums here all night and I'm about to tear all my hair out. I am properly rendering 4 editboxes and they fire events properly, as do 2 buttons. However, no matter what I do, I cannot access the editboxes. The mouse cursor changes on hover but the boxes themselves cannot be interacted with. As this is a full ogre program I'm not sure what I should post from it but the boxes all adhere to this basic structure

Code: Select all

CEGUI::Window *inRows = wmgr.createWindow("TaharezLook/Editbox", "root/inRows");
   sheet->addChild(inRows);
   inRows->setSize(CEGUI::USize(CEGUI::UDim(0.15, 0), CEGUI::UDim(0.05, 0)));
   inRows->setPosition(CEGUI::UVector2(CEGUI::UDim(.05, 0), CEGUI::UDim(.1, 0)));
   inRows->setText("");
   inRows->setTextParsingEnabled(true);
   inRows->subscribeEvent(CEGUI::Window::EventMouseButtonDown, CEGUI::Event::Subscriber
      (&TutorialApplication::newRows, this));
   inRows->setEnabled(true);
   rowRef = inRows; //global reference


and sheet is defined as

Code: Select all

CEGUI::WindowManager &wmgr = CEGUI::WindowManager::getSingleton();
   CEGUI::Window *sheet = wmgr.createWindow("DefaultWindow", "root/Sheet");
   CEGUI::System::getSingleton().getDefaultGUIContext().setRootWindow(sheet);
   sheet->setMousePassThroughEnabled(true);

any insight is much appreciated.

note that I am aware the events are set as window events: this was done to test whether input was working. I am also aware I can cast the editbox windows to editboxes and tweak the events and none of this has affected my dilema...
Last edited by Arikaido on Sat Apr 09, 2016 22:44, edited 1 time in total.

User avatar
Ident
CEGUI Team
Posts: 1998
Joined: Sat Oct 31, 2009 13:57
Location: Austria

Re: Editboxes with OIS and Ogre3d

Postby Ident » Sat Apr 09, 2016 09:32

Code: Select all

 sheet->setMousePassThroughEnabled(true);

That's the default, not necessary to set it.

You did not tell us which CEGUI version you use.

You are subscribing a mouse button down handler, are you by any chance returning true on it?
CrazyEddie: "I don't like GUIs"

lucebac
Just can't stay away
Just can't stay away
Posts: 193
Joined: Sat May 24, 2014 21:55

Re: Editboxes with OIS and Ogre3d

Postby lucebac » Sat Apr 09, 2016 10:10

Code: Select all

using namespace CEGUI;
Window* root = winMgr.createWindow("DefaultWindow", "root");
System::getSingleton().getDefaultGUIContext().setRootWindow(root);

// and for each editbox do:
Editbox* box = static_cast<Editbox*>(winMgr.createWindow("TaharezLook/Editbox", "unified_name_here"));
// (re)size box, move box, set properties on box, etc
root->addChild(box);
// done

This should do the trick. You should NOT name your windows like "root/editbox_1" since this will break the window manager presumably. CEGUI's internal window handling is like folders on a HDD. You don't give your folders names like "Programs/Game1" but you go into the "Programs" folder and add a folder named "Game1". The same goes for windows in CEGUI. Just give your windows unique names and add them to their parent window as a child.

You can acces the editboxes afterwards by:

Code: Select all

Editbox* box = static_cast<Editbox*>(root->getChild("relative_path_and_window_name_as_seen_from_root"));

Arikaido
Just popping in
Just popping in
Posts: 4
Joined: Sat Apr 09, 2016 09:00

Re: Editboxes with OIS and Ogre3d

Postby Arikaido » Sat Apr 09, 2016 17:10

Sorry, I'm using .8 in MSVS2013 and actually all the handlers do is return false...

I rewrote the boxes as lucebac suggested:

Code: Select all

CEGUI::Editbox *inRows = static_cast<CEGUI::Editbox*>
      (wmgr.createWindow("TaharezLook/Editbox", "inRows"));
   inRows->setSize(CEGUI::USize(CEGUI::UDim(0.15, 0), CEGUI::UDim(0.05, 0)));
   inRows->setPosition(CEGUI::UVector2(CEGUI::UDim(.05, 0), CEGUI::UDim(.1, 0)));
   inRows->setText("");
   inRows->setTextParsingEnabled(true);
   inRows->subscribeEvent(CEGUI::Window::EventMouseButtonDown, CEGUI::Event::Subscriber
      (&TutorialApplication::newRows, this));
   inRows->setEnabled(true);
   rowRef = inRows; //a global reference
   sheet->addChild(inRows);


still no dice. I'm not incredibly familiar with CEGUI and this is really bizarre behavior to me, so if anybody knows why an editbox cannot be edited (for any reason) I'm pretty much at a loss as it stands.

lucebac
Just can't stay away
Just can't stay away
Posts: 193
Joined: Sat May 24, 2014 21:55

Re: Editboxes with OIS and Ogre3d

Postby lucebac » Sat Apr 09, 2016 17:25

Arikaido wrote:and actually all the handlers do is return false

The handlers need to return true.

Arikaido
Just popping in
Just popping in
Posts: 4
Joined: Sat Apr 09, 2016 09:00

Re: Editboxes with OIS and Ogre3d

Postby Arikaido » Sat Apr 09, 2016 17:32

Alright, now they do. Still nothing. The cursor changes over the boxes but clicking does nothing. Like I said, they fire events, so what could be the problem here?

Arikaido
Just popping in
Just popping in
Posts: 4
Joined: Sat Apr 09, 2016 09:00

Re: Editboxes with OIS and Ogre3d

Postby Arikaido » Sat Apr 09, 2016 17:44

And I knew this was a rat's nest, but I've made progress. In my mousePressed function the switch statement used to convert OIS inputs to CEGUI inputs had break statements (as any goood switch should??) and deleting these breaks in the mousePressed and mouse Released functions did the trick. Sorry for wasting you guys' time and thanks for it. :oops:

User avatar
Ident
CEGUI Team
Posts: 1998
Joined: Sat Oct 31, 2009 13:57
Location: Austria

Re: Editboxes with OIS and Ogre3d

Postby Ident » Sat Apr 09, 2016 18:10

lucebac wrote:
Arikaido wrote:and actually all the handlers do is return false

The handlers need to return true.

If they return true then the event will be seen as handled and CEGUI won't do what it normally would do when it is handled. For the non-invase approach you wanna return false and that should be the default. There is of course cases when it must be true.

Arikaido wrote:And I knew this was a rat's nest, but I've made progress. In my mousePressed function the switch statement used to convert OIS inputs to CEGUI inputs had break statements (as any goood switch should??) and deleting these breaks in the mousePressed and mouse Released functions did the trick. Sorry for wasting you guys' time and thanks for it. :oops:



Can happen to anyone ;) please always put the thread on [Solved] tho since you got a solution.
CrazyEddie: "I don't like GUIs"

lucebac
Just can't stay away
Just can't stay away
Posts: 193
Joined: Sat May 24, 2014 21:55

Re: Editboxes with OIS and Ogre3d

Postby lucebac » Sat Apr 09, 2016 22:08

Arikaido wrote:In my mousePressed function the switch statement used to convert OIS inputs to CEGUI inputs had break statements (as any goood switch should??) and deleting these breaks in the mousePressed and mouse Released functions did the trick.

Are you sure that removing the break keywords from your switch statement is the right way to solve your problem? Removing all breaks in your code will convert your switch to something like

Code: Select all

if (variable == 1) goto case_1;
else if (variable == 2) goto case_2;
[...]
else goto default_case;

case_1: // do case_1 stuff and everything that follows
case_2: // do case_2 stuff and everything that follows
[...]
default_case: // do default stuff

And regardless of what the code should do, it will definitely don't do it in the way you expect (since you changed the semantics of your code by eliminating all breaks). Long story short: you need the breaks to finish each switch case and you can't just remove them.
You can run this code to see what I try to say:

Code: Select all

#include <iostream>

int main(int argc, char** argv)
{
    int num = 2;
   
    std::cout << "Switch with break:" << std::endl;
   
    switch (num)
    {
    case 1:
        std::cout << "case 1" << std::endl;
        break;
       
    case 2:
        std::cout << "case 2" << std::endl;
        break;
       
    case 3:
        std::cout << "case 3" << std::endl;
        break;
       
    default:
        std::cout << "default case " << std::endl;
        break;
    }
   
    std::cout << std::endl << "switch w/o break:" << std::endl;
   
    switch (num)
    {
    case 1:
        std::cout << "case 1" << std::endl;
       
    case 2:
        std::cout << "case 2" << std::endl;
       
    case 3:
        std::cout << "case 3" << std::endl;
       
    default:
        std::cout << "default case " << std::endl;
    }
   
    return 0;
}

User avatar
Ident
CEGUI Team
Posts: 1998
Joined: Sat Oct 31, 2009 13:57
Location: Austria

Re: [Solved] Editboxes with OIS and Ogre3d

Postby Ident » Sat Apr 09, 2016 23:19

Lucebac, you are right of course. I thought the point was though that Arikaido now knows what to look at to fix. @Arikaido: In no way was I trying to say that just removing the breaks "fixes" the switch-case :D
CrazyEddie: "I don't like GUIs"


Return to “Help”

Who is online

Users browsing this forum: No registered users and 25 guests