I used to use windowLit() to determine if the mouse was over
any gui window. I didn't care which window, I just want to know if it is point at any window at all. This way I can prevent user input in the scene while the cursor is over a window. Now that windowLit() has been removed (back in September 2011), I had to find an alternative way to achieve this. So I have started doing this now instead.
Code:
if(Gui.msLit() && Gui.msLit()->type() != GO_DESKTOP)
{
// The mouse is over a gui object, so we cannot process input in the scene.
}
else
{
// The mouse is not over any gui object so input can be processed in the scene.
}
This seems to work ok, but it is just long winded in comparison to the old method of doing this. Is this the correct way to handle this situation now or is there a better way?
On a side note. I was hoping to use Ms.eat() to eat all mouse buton input when the mouse is over a gui object, so that it doesn't pass down to the scene. I don't want mouse buttons clicks to register in the scene when the user clicks a button in the gui. However it doesn't seem to work this way. Here is what I'd like to do in the app update method every frame (pseudo-code).
Code:
Game::World.update( Cam.at );
Cam.set();
if( mouse over gui )
Ms.eat();
// Update the scene... if the mouse was over a gui object this frame, then the mouse input has been eaten so it can't affect the scene.
scene.update();
This approach doesn't work as it causes the input to be eaten for the gui as well. I'm guessing under the bonnet that EE calls the app's update() method before calling the gui's update methods internally. Is there some way around this or a known way to block input in the scene when the mouse is over a gui window that I haven't found yet.