Unfocusing from GUI

Apr 14, 2010 at 12:55 AM

Hi -

I just started using the Nuclex GUI package, and, although I like it so far, I have run into a problem.  Your GUI seems to be a focus-hog (i.e., when I click elsewhere within the window, even in space not on the game's "Desktop", the GUI elements retain focus, and thus when I press keys for other functions, they both get entered into the currently focused input and get captured by my application's input handling.  Is there a(n easy) way to remove the focus from the GUI?


Best Regards,


Apr 14, 2010 at 6:07 PM

Yep, that's a problem currently. I designed the GUI with the expectation that it would be used either exclusively (eg. main menu, ingame pause menu, etc.) or not at all, but didn't cover the case that the GUI might be used in parallel to the running game.

I'm already working on a solution (check this thread: http://nuclexframework.codeplex.com/Thread/View.aspx?ThreadId=81004), but I'm making slow progress at the moment because I'm a bit stressed-out with other work. I hope to have something ready in 2-3 weeks from now.

You can control which input the GUI gets by assigning your own IInputCapturer implementation to the GuiManager.InputCapturer property (possibly one delegating from the original InputCapturer only if the GUI should have focus). It's also possibly to disable the InputCapturer completely and passing input to the Screen yourself by calling its Inject...() methods.

This is only an imperfect workaround, of course.

Sep 2, 2010 at 10:42 AM

This should be solved now in the upcoming release (and right now in the SVN trunk). Sorry it took a bit longer than 2-3 weeks (more like 3-4 months *yikes*).

I will also add the option of making the desktop window focusable (the desktop window is basically the GUI's representation of the blank space outside of any GUI elements) so even keyboard input that would normally be interpreted as hot keys (eg. enter presses the default button on the focused dialog) will then go to the game instead.

If this is used, the game should probably provide a game pad button that refocuses the GUI, otherwise a pure game pad user wouldn't be able to interact with the GUI anymore once it loses focus.