Game Development Reference
In-Depth Information
Hot Keys
An excellent property to attach to any control on a desktop game is a hot key. As
players become more familiar with the game, they
ll want to ditch the pointer control
in favor of pressing a single key on the keyboard. It
'
s faster, which makes hard-core
players really happy. You can distinguish between a hot key command and a normal
keyboard input by checking the keyboard focus. The focus is something your screen
class keeps track of itself, since it is an object that moves from control to control.
Let
'
s assume that you have a bunch of button controls on a game screen, as well as
a chat window. Normally, every key down and up event will get sent to the controls
to see if any of their hot keys match. If they do match, the OnControl() method of
the screen will get called. The only way to enable the chat window is to click it with
the mouse or provide a hot key for it that will set the keyboard focus for the screen.
As long as the keyboard focus points to the chat control, every keyboard event will be
sent there, and hot keys are essentially disabled. Usually, the focus is released when
the edit control decides it
'
s done with keyboard input, such as when the Enter key is
pressed. The focus can also be taken away by the screen, for example, if a different
control were to be activated by the mouse.
'
Tooltips
Tooltips are usually controlled by the containing screen, since it has to be aware of
moving the tooltip around as different controls are highlighted. Tooltips are trickier
than you
s much more to enabling them than creating a bit of
text on your screen for each control.
For one thing, every tooltip needs to have a good position relative to the control it
describes. You can
'
d think, because there
'
t just assume that every tooltip will look right if you place it in the
same relative position to every control. If you decide that every tooltip will be placed
in the upper-right area of every control, what happens when a control is already at
the upper-right border of the screen? Also, you
'
'
ll want to make sure that tooltips
don
'
t cover other important information on the screen when they appear. You don
'
t
want to annoy the heck out of your users.
Tooltips Don
'
t Do Much Good Off-Screen
Even if you provide a placement hint, such as above or beside a control, you
'
ll
still need to tweak the placement of the tooltip to make sure it doesn
t clip on
the screen edge. Also, make sure that screens can erase tooltips prematurely,
such as when a dialog box appears or when a drag begins.
'
 
 
 
Search WWH ::




Custom Search