im having what i assume is a pretty simple problem to solve, hope someone can help...
im using ogre, and ois to inject my input into cegui.
in my CreateScene function i do:
Code: Select all
CEGUI::WindowManager *win = CEGUI::WindowManager::getSingletonPtr();
CEGUI::Window *sheet = win->createWindow("DefaultGUISheet", "Game3/Sheet");
CEGUI::Window *myButton = win->createWindow("TaharezLook/Button", "Game3/MyButton");
quit->setText("MyButton");
CEGUI::UVector2 pos(CEGUI::UDim(0.0, 0), CEGUI::UDim(0.0, 0));
quit->setPosition(pos);
quit->setSize(CEGUI::UVector2(CEGUI::UDim(0.15, 0), CEGUI::UDim(0.025, 0)));
quit->subscribeEvent(CEGUI::PushButton::EventMouseButtonDown, CEGUI::Event::Subscriber(&Application::MyFunction, this));
sheet->addChildWindow(myButton);
mSystem->setGUISheet(sheet);
so as you can see, i just create quite a small button, place it top-left, and set its EventMouseButtonDown to a function called MyFunction in my Application class:
The mousePressed function (from OIS) is what injects the mouse pressed into CEGUI, like this:
Code: Select all
CEGUI::MouseButton mb = ConvertOIStoCEGUI(id);
CEGUI::System *sys = CEGUI::System::getSingletonPtr();
sys->injectMousePosition(arg.state.X.rel, arg.state.Y.rel);
sys->injectMouseButtonDown(mb);
now, when i click on the button for the first time, the MyFunction function is called, and all is good. but the problem is that from that point on, the MyFunction function is called EVERY time the mouse button is clicked, no matter where the mouse is. so as you can see from my code, the button is placed at (0,0), ie top left. i can click the mouse button anywhere on the window, even bottom right, and the MyFunction function is called.
i use:
Code: Select all
CEGUI::Window* pWindow = CEGUI::System::getSingleton().getWindowContainingMouse();
CEGUI::String name = pWindow->getName();
at the time the mouse is clicked and it always returns the name of the button !
i must be doing something daft. any help appreciated.