Widget::HandleKeyboardEvent
Defined in:
Called when the user interacts with a widget using the keyboard.
C4Widgets.h
Prototype
virtual bool HandleKeyboardEvent(const KeyboardEventData *eventData);
Parameters
eventData |
A pointer to the event data. |
Description
The HandleKeyboardEvent
function should be overridden by subclasses of the Widget
class that need to respond to keyboard interaction from the user. This function is called by the Interface Manager when the user uses the keyboard while a widget has the keyboard focus. A widget subclass implementation indicates that it is able to receive the keyboard focus by specifying the kWidgetKeyboardFocus
usage flag in a call to the Widget::SetWidgetUsage
function.The
eventType
field of the KeyboardEventData
structure can be one of the following constants.
kEventKeyDown |
The user pressed a key. If the key is held in long enough for auto-repeat, then this event can be received more than once before the corresponding key up event is received. |
kEventKeyUp |
The user released a key. |
kEventKeyCommand |
The user pressed a key while the Control key was pressed (or on the Mac, when the Command key was pressed). |
HandleKeyboardEvent
function should return true
if it handled the event and false
otherwise. For subclasses of the Window
class, the implementation should call the HandleKeyboardEvent
function for the Window
base class when a keyboard event is not handled, and it should return whatever value was returned by that function.
See Also