Ignoring Events on Sheets

rubasurex

06-02-2009 15:00:03

I'm building an editor for my project and I'm using a ToolBar along the top of the screen with menus. When I inject mouse input into QuickGUI, I check the return value of the inject method. If it returns false, then I pass the input event onto the editor, otherwise I don't. This ensures that mouse input that occurs over a menu item (such as a button press) for example, does not cause the editor to modify the scene underneath.

So far, this has been working great, except for one small problem. After I have finished interacting with the menu (i.e. I've clicked on a menu item), the next time I click somewhere in the scene, it does not immediately pass the input through to the editor. The inject method for the mouse button press returns true, even though I have clicked on something in my scene and not on any widgets. However, when I click a second time, it then works and continues to work as per normal until I interact with the menu again.

I've figured out what is going on. I have a sheet that stretches the entire screen. When you interact with the menu, the sheet loses focus. Then the next time you click on the scene, QuickGUI reads it as a click on the sheet and handles it as a receive focus event on the sheet, even though the area of the sheet you click on is completely transparent (i.e. no widgets).

What I really need is a way to allow these focus event to pass straight through the sheet. Perhaps the sheet could just ignore these events since sheets (as far as I'm aware) are never used for anything visually. They are just containers for widgets. Therefore, a sheet should never need to receive focus and should let input pass right through it.

kungfoomasta

06-02-2009 19:35:43

I do the same as you, although I didn't realize a recent change I made would raise this issue. (I haven't worked on my other project in a while :P )

You're right about how the events work. The Sheet is a Window without a titlebar, since the Window class is the only class that creates a Texture. (Each window is a texture that is built and drawn onto the screen) I recently added in the functionality where Windows get notified when they gain and lose focus, it was the easiest way to dismiss menus when a widget outside the menu is clicked.

I will review the code and see why true is being returned when the Sheet gains focus. Ideally, injections should only return true if a user defined event handler has been called. The current problem is that I mix internally created Event Handlers with user defined ones. The solution is in the addition of the CallbackManager class I outlined in another thread.

As a temporary solution, you could add an event handler to the sheet, for mouseButtonDown/Up/Click/etc, and just pass the mouse click on to your non GUI event system.

Thanks for pointing this out, it needs to be fixed, as your scenario is most likely the norm.

rubasurex

08-02-2009 04:15:23

In addition, I have discovered that the injectMouseWheelChange appears to always return true, even when the mouse is not over any visible widget. I'm assuming that because the focus is still on the sheet and the mouse is indeed over the sheet (since it stretches the entire screen) that the sheet is handling the mouse wheel scroll (even though it does nothing with it). In my editor I'm using the mouse wheel to control zoom. Since the sheet always handles it, I can no longer zoom.

One more question (off topic), is there an easy way to ensure that a sheet always stretches exactly over the entire screen, even if the resolution changes? Can it be linked to a viewport or something like that so it automatically resizes if the viewport is resized? Or do I need to manually resize my sheets if the user changes resolution or resizes the window?

kungfoomasta

08-02-2009 07:02:27

Regarding the mouse wheel events always returning true, this is most likely because the sheet supports scrolling. If you create the sheet with 'containerwidget_supportScrollBars = false', scrolling with the mouse over the sheet should return false. This also falls under the issue raised above, and only user-defined scenarios should be used to determine that an event has been handled. This will be fixed by next release.

One more question (off topic), is there an easy way to ensure that a sheet always stretches exactly over the entire screen, even if the resolution changes?

In my scenario, since the viewport always matches the render window size, I listen for window resizing events, and update the corresponding GUIManager then. QuickGUI will work with any viewport, and I didn't find any way to listen for viewport size changes. The alternative would be to poll the viewport every time the GUI is drawn, but that would be very inneficient, especially when the common scenario is easily handled.

rubasurex

08-02-2009 07:14:45

In my scenario, since the viewport always matches the render window size, I listen for window resizing events, and update the corresponding GUIManager then. QuickGUI will work with any viewport, and I didn't find any way to listen for viewport size changes. The alternative would be to poll the viewport every time the GUI is drawn, but that would be very inneficient, especially when the common scenario is easily handled.
Ah OK, sorry I meant the render window, not the viewport.

So are you saying that QuickGUI listens for window resizing events or do you mean that I should be doing that and then passing the resize through to QuickGUI? If you mean the latter, then where do I pass that to GUIManager? I've already had a look through its interface but couldn't find anything obvious (like windowResize() for example). My only thought would be to resize each of my sheets individually.

kungfoomasta

08-02-2009 18:45:33

Hm, I looked up the current API and it looks like I no longer use a "_notifyViewportDimensionsChanged" function. I think the reason for this is that I didn't want to assume the Sheet will always be the size of the viewport. When I go to make the editor, I want to allow creating sheets that are 1600 x 1200, even if the render window is only 800 x 600. (Scrolling will have to come into play here) It seems that in your case you would need to refit all your Sheets. (in the render window resize handler function)