Sign in to follow this  
Raeldor

Game Gui Design and Keyboard Focus

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
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

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this