• Advertisement
Sign in to follow this  

Game Gui Design and Keyboard Focus

This topic is 4123 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi All, Just trying to figure out the design for my game Gui. I want to implement a full windows-type interface with frame windows (including scrolling), and controls such as textbox, checkbox, drop down etc. My first question though is about control focus. Games seem to work a little differently to regular windows applications in as much as the game itself mostly has focus to receive keypress events to control actions in the game. It seems most games utilize windows purely for display only with some mouse interaction, but usually not keyboard interaction and they never seem to 'take focus'. The only dialogs that seem to take focus and keyboard interaction are always modal. Is this an accurate statement? Are most games designed this way to keep the focus in the game itself? I can't think of a way of a window taking focus for keyboard events without having the user needing to click back into the game area to refocus keyboard events back to the game (which seems like a REALLY bad idea). Any comments/suggestions/thoughts would be appreciated. Thanks! Rael

Share this post


Link to post
Share on other sites
Advertisement
Quote:
Original post by yckx
Is there any reason SetFocus wouldn't work, or do I misunderstand your question?

I am not using Windows programming, I am writing my own GUI.

Share this post


Link to post
Share on other sites
What you want to do is allow each window to "see" the input regardless of which window has the focus.

If you had an "InputData" structure which described the key being pressed, you could have an internal flag "processed" which lets every other window know that the input had been processed (but they can still process it if they want to).

In this regard, the player might be typing in the chat window and moving around at the same time. The chat window (since it has the focus) will process all of the character keys, and set InputData.processed to true. When the game window gets the input, it will be able to see that the input has been processed (though it could still process it again if it wanted).

When the chat window sees an arrow key being pressed, it will ignore the input, and the game window will process it etc.

Share this post


Link to post
Share on other sites
You can always use Escape on non-modal text areas in your game (the chat is the usual one) to return focus to the 'null control' (i.e. straight to the game engine).

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement