[Solved] eventMouseButtonClick delegate not being called

Binkster

23-07-2012 15:40:36

Hey there!

I've recently rebooted an old project of mine. I used to be in VS2005 with Ogre 1.6 and CEGUI, but since the latter was discontinued and I prefer to work in VS2010 nowadays, I've converted the project to Ogre 1.7.4 and changed to MyGUI 3.2.0 . Unfortunatly these things never really work out of the box for me. I've been bumping in this problem for weeks now, and I figure it's time for professional help:

In main.cpp I initialize MyGui
mPlatform = new MyGUI::OgrePlatform();
mPlatform->initialise(win, mSceneMgr);
mGUI = new MyGUI::Gui();
mGUI->initialise();
mPlatform->getRenderManagerPtr()->setActiveViewport(win->getNumViewports()-1);


In InputHandler I find out about OIS event, ie
bool InputHandler::mousePressed(const OIS::MouseEvent &evt, OIS::MouseButtonID btn)
{

MyGUI::InputManager::getInstance().injectMousePress(evt.state.X.abs, evt.state.Y.abs, MyGUI::MouseButton::Enum(btn));
if (m_simulation)
m_simulation->mousePressed(evt, btn);
return true;
}


In MainMenuDlg I create MyGUI widgets within its constructor:
MainMenuDlg::MainMenuDlg(MyGUI::Gui* mgui, InputFrameListener *pSimulation)
{
mGUI = mgui;
{....}
MyGUI::ButtonPtr pQuitButton = mGUI->createWidget<MyGUI::Button>("Button", 0, 0, 80, 30, MyGUI::Align::Default, "Main");
pQuitButton->setCaption("Quit");
pQuitButton->eventMouseButtonClick += MyGUI::newDelegate(this, &MainMenuDlg::Quit_OnClick);

}


Then there's the callback function
void MainMenuDlg::Quit_OnClick(MyGUI::WidgetPtr sender)
{
m_pSimulation->mContinue = false;
}


Most of this all works fine, the project runs, I'm seeing the button and a mouse pointed, and upon clicking anywhere, the InputHandler::mousePressed is called. The Quit_OnClick in MainMenuDlg however, is never entered.

Afaik, I've followed all the steps in QuickStart, the rest of the MyGUI documentation/FAQs and godknowshowmany threads/google searches. Could anyone tell me what I'm missing?

Blender2Ogre

23-07-2012 23:24:37

hi,
maybe you are missing this :

bool InputHandler::mouseReleased(const OIS::MouseEvent& arg, OIS::MouseButtonID id)
{
MyGUI::InputManager::getInstance().injectMouseRelease(arg.state.X.abs, arg.state.Y.abs, MyGUI::MouseButton::Enum(id));
return true;
}

at the beggining it wouldnt work for me neither if i had not set that too!
i hope this helps,
Kind regards,
Romulo Romero

Binkster

24-07-2012 10:51:16

Thanks for the reply, but I do have that. I figured the click would be triggered after both a press and release event

bool InputHandler::mouseReleased(const OIS::MouseEvent &evt, OIS::MouseButtonID btn)
{
MyGUI::InputManager::getInstance().injectMousePress(evt.state.X.abs, evt.state.Y.abs, MyGUI::MouseButton::Enum(btn));
...
return true;
}


...

...

Sooooo, I reckon I should have injectMouseRelease there instead..

/facepalm

Blender2Ogre

24-07-2012 15:52:32

hahahah the same happened to me a while ago..yeah copying and pasting sometimes makes that happen^^, im glad it worked now :D