I've got a menu strip with three buttons on it, arranged like the image below.
What I want is for any click inside the grey area (the menu bar) to be consumed, and any click outside that area to be passed to the game. I thought I could accomplish this by simply checking the return value of InjectMouseButtonDown. If it was false, then I didn't click on the GUI.
Here's the code I'm using:
Code: Select all
if (_mouseState.LeftPressed)
if (CEGUI::System::getSingleton().injectMouseButtonDown(CEGUI::LeftButton) == false)
OnLeftPressed();
if (_mouseState.RightPressed)
if (CEGUI::System::getSingleton().injectMouseButtonDown(CEGUI::RightButton) == false)
OnRightPressed();
_mouseState is just a small struct to hold information about the mouse.
Well, it doesn't seem to work correctly. When I click on the buttons (the empty squares) everything works correctly, and no click is passed to the game. But when I click on the grey area, the click is sometimes passed on and sometimes consumed. It seems to consume the first click, and pass on every subsequent one.
Is there a better way to check to see if my mouse is over a visibile GUI element? Would I have to maintain a list of rectangles and check every one before handling click events? Am I missing something obvious?
