mousePressed, bypass QuickGUI when necessary

tod

03-02-2008 22:09:20

I have a simple question, yet I could not find an answer on this forum, sorry if it is redundant.
My problem is, I have a mousePressed event handler and I inject the event into QuickGUI. What I want is: If the mouse press event doesn't touch any QuickGUI widget I want it to do some other stuff on my scene. As I can see the injectMouseButtonDown always returns true.
Is there any way to know if the mouse press was (or can be) handled by QuickGUI?
Thanks.

tod

03-02-2008 22:21:29

I have found some rather ugly workaround for my specific case, but please enlighten me on a more normal approach.

virtual bool mousePressed( const OIS::MouseEvent &arg, OIS::MouseButtonID id )
{
if(mGUIManager->getMouseOverWidget() != mGUIManager->getDefaultSheet())
{
mGUIManager->injectMouseButtonDown(static_cast<QuickGUI::MouseButtonID>(id));
}
else
{
//do stuff
}
}

kungfoomasta

04-02-2008 07:16:13

Why does it always return true? It only returns true if it has fired an event.

tod

04-02-2008 08:20:39

My mistake, it always returns false, but that doesn't really help me :wink: .
bool GUIManager::injectMouseButtonDown(const MouseButtonID& button)
{
if( !mMouseCursor->isVisible() )
return false;

bool eventHandled = false;

_handleMouseDown(button);
/*
if(mMouseButtonEvents.empty())
{
mMouseButtonEvents.push_back(Widget::EVENT_MOUSE_BUTTON_DOWN);
mUseMouseTimer = true;
mMouseTimer = 0;
mMouseButtonDown[button] = mWidgetContainingMouse;
return ((mWidgetContainingMouse->getNumberOfHandlers(Widget::EVENT_MOUSE_BUTTON_DOWN) > 0) ||
(mWidgetContainingMouse->getNumberOfHandlers(Widget::EVENT_MOUSE_CLICK) > 0) ||
(mWidgetContainingMouse->getNumberOfHandlers(Widget::EVENT_MOUSE_CLICK_DOUBLE) > 0));
}

if((mMouseButtonEvents.front() == Widget::EVENT_MOUSE_CLICK) && (mMouseButtonDown[button] != mWidgetContainingMouse))
return false;

if(mMouseButtonEvents.front() == Widget::EVENT_MOUSE_CLICK_DOUBLE)
return false;

mMouseButtonEvents.push_back(Widget::EVENT_MOUSE_BUTTON_DOWN);
*/

return eventHandled;
}

kungfoomasta

04-02-2008 17:13:00

It looks like its commented out from the zip file I uploaded. The SVN version doesn't have this issue, although I'm at work and can't review the code to verify. The intended behavior is to return true only if an event was fired.

Are you able to grab the code from SVN?