Symbian
Symbian Developer Library

SYMBIAN OS V9.4

Feedback

[Index] [Previous] [Next]


How to process window-group related events

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.

[Top]


Key events

To detect if a key event has occured, use the EEventKey, EEventKeyUp or EEventKeyDown event types.

You can get get key event information by calling the 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;
                    }

[Top]


Modifier changed events

To detect if a key modifer (the state of SHIFT, CTRL, etc. keys) changed event has occured, use the EEventModifiersChanged event type.

You can get key event information by calling the 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 modifers: values are defined in TEventModifier
                    TUint modifiers = keyEvent.iModifiers;
                    break;
                    }

This event type is not reported unless explicitly requested by a window. Use RWindowTreeNode::EnableModifierChangedEvents() to request this event type.

[Top]


Window focus lost and gained events

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

[Top]


User-defined event received from another window

To detect if user-defined events have been received from another window, use EEventUser.

You can get information about the event by calling TWsEvent::EventData().

         // User-defined event received from another window
         case EEventUser:
                    { 
                    // Get a pointer to the event data
                    TAny* data = iWsEvent.EventData();
                    }