The following examples demonstrate how to get window-group related event types, which are global within the window group and include: key events, modifier changed events, window focus lost and gained events and user defined events.
Variant: ScreenPlay and non-ScreenPlay. Target audience: Application developers.
To detect if a key event has occurred, use the EEventKey
, EEventKeyUp
or EEventKeyDown
event types.
You can get key event information by calling the [[[ERROR: [NOKX000E] Unable to find definition for key reference 'TWsEvent']]]TWsEvent::Key()
function.
// Key events - get the key code case EEventKey: case EEventKeyUp: case EEventKeyDown: { // Get the key event TKeyEvent& keyEvent=*iWsEvent.Key(); // Get the key code: values are defined in TKeyEvent TUint code = keyEvent.iCode; break; }
To detect if a key modifier (the state of SHIFT, CTRL, etc. keys) changed event has occurred, use the EEventModifiersChanged
event type.
You can get key event information by calling the [[[ERROR: [NOKX000E] Unable to find definition for key reference 'TWsEvent']]]TWsEvent::ModifiersChanged()
function.
// A key modifier (e.g. SHIFT) changed case EEventModifiersChanged: { // Get the state of the modifier keys TKeyEvent& keyEvent=*iWsEvent.ModifiersChanged(); // Get the key modifiers: values are defined in TEventModifier TUint modifiers = keyEvent.iModifiers; break; }
This event type is not reported unless explicitly requested by a window. Use [[[ERROR: [NOKX000E] Unable to find definition for key reference 'TWsEvent']]]RWindowTreeNode::EnableModifierChangedEvents()
to request this event type.
To detect if the window focus has been lost or gained, use the EEventFocusLost
and EEventFocusGained
event types.
You can get the handle to the window group whose focus has changed by calling [[[ERROR: [NOKX000E] Unable to find definition for key reference 'TWsEvent']]]TWsEvent::Handle()
.
// Window focus lost and gained events case EEventFocusLost: case EEventFocusGained: { // Get handle (typically a pointer) to the window group whose focus has changed TUint handle = iWsEvent.Handle(); break; }
To detect if user-defined events have been received from another window, use EEventUser
.
You can get information about the event by calling [[[ERROR: [NOKX000E] Unable to find definition for key reference 'TWsEvent']]]TWsEvent::EventData()
.
// User-defined event received from another window case EEventUser: { // Get a pointer to the event data TAny* data = iWsEvent.EventData(); }