Application-specific events

CCoeAppUi:HandleApplicationSpecificEventL() is called for application-specific events where event codes are from EEventUser upwards in TEventCode. You can define a data structure to be delivered in the window server event. The data can be accessed through a pointer, which can be obtained by calling TWsEvent::EventData(). The maximum event data size is defined as EWsEventDataSize.

void HandleApplicationSpecificEventL(TInt aType,const TWsEvent& aEvent)

Code example:

First define a data structure for the event data:

class TEventsEventType
        // Event iData
        TBufC< TWsEvent::EWsEventDataSize> data;

Then create an event and send it to all window groups:

// Create a window server event
TWsEvent event;
TEventsEventType eventType;
// Set event data. = KData;
event.SetType( ETestEvent1 ); // set event type
event.SetTimeNow(); // set the event time
event.SetHandle( iWsSession.WsHandle() ); // set window server handle
*( TEventsEventType* )( event.EventData() ) = eventType; // set event data
// Send the created event
User::LeaveIfError( iWsSession.SendEventToAllWindowGroups( event ) );

Catch the event using the following method:

void CEventsAppUi::HandleApplicationSpecificEventL(TInt aType,const TWsEvent& aEvent)
    // Check the event type
    if( aType == ETestEvent1 )
        // Cast to TEventsEventType
        TEventsEventType event;
        event = *( TEventsEventType* )aEvent.EventData();
        // Print the data
        iEikonEnv->InfoMsg( );
        // Call the base class implementation
        CEikAppUi::HandleApplicationSpecificEventL( aType, aEvent );