Symbian3/SDK/Source/GUID-95DD1440-01C9-4997-8DD4-FFD33D7DEAFF.dita
changeset 0 89d6a7a84779
equal deleted inserted replaced
-1:000000000000 0:89d6a7a84779
       
     1 <?xml version="1.0" encoding="utf-8"?>
       
     2 <!-- Copyright (c) 2007-2010 Nokia Corporation and/or its subsidiary(-ies) All rights reserved. -->
       
     3 <!-- This component and the accompanying materials are made available under the terms of the License 
       
     4 "Eclipse Public License v1.0" which accompanies this distribution, 
       
     5 and is available at the URL "http://www.eclipse.org/legal/epl-v10.html". -->
       
     6 <!-- Initial Contributors:
       
     7     Nokia Corporation - initial contribution.
       
     8 Contributors: 
       
     9 -->
       
    10 <!DOCTYPE concept
       
    11   PUBLIC "-//OASIS//DTD DITA Concept//EN" "concept.dtd">
       
    12 <concept id="GUID-95DD1440-01C9-4997-8DD4-FFD33D7DEAFF" xml:lang="en"><title>Application-specific
       
    13 events</title><prolog><metadata><keywords/></metadata></prolog><conbody>
       
    14 <p><xref href="jar:GUID-35228542-8C95-4849-A73F-2B4F082F0C44.jar!/sdk/doc_source/reference/reference-cpp/Control_Environment/CCoeAppUiClass.html#%3a%3aCCoeAppUi%3a%3aHandleApplicationSpecificEventL%28TInt%2cconst%20TWsEvent%20%26amp%3b%29" format="application/java-archive"><parmname>CCoeAppUi:HandleApplicationSpecificEventL()</parmname></xref> is
       
    15 called for application-specific events where event codes are from <xref href="jar:GUID-35228542-8C95-4849-A73F-2B4F082F0C44.jar!/sdk/doc_source/reference/reference-cpp/Window_Server/TKeyEventStruct.html" format="application/java-archive"><parmname>EEventUser</parmname></xref> upwards in <parmname>TEventCode</parmname>. You can define
       
    16 a data structure to be delivered in the window server event. The data can
       
    17 be accessed through a pointer, which can be obtained by calling<xref href="jar:GUID-35228542-8C95-4849-A73F-2B4F082F0C44.jar!/sdk/doc_source/reference/reference-cpp/Window_Server/TWsEventClass.html#%3a%3aTWsEvent%3a%3aEventData%28%29const" format="application/java-archive"><parmname> TWsEvent::EventData()</parmname></xref>. The maximum event
       
    18 data size is defined as <xref href="jar:GUID-35228542-8C95-4849-A73F-2B4F082F0C44.jar!/sdk/doc_source/reference/reference-cpp/Window_Server/TWsEventClass.html#%3a%3aTWsEvent%3a%3aEWsEventDataSize" format="application/java-archive"><parmname>EWsEventDataSize</parmname></xref>. </p>
       
    19 <codeblock id="GUID-80335267-13AB-49C8-8895-B6598F5D59A4" xml:space="preserve">void HandleApplicationSpecificEventL(TInt aType,const TWsEvent&amp; aEvent)
       
    20 </codeblock>
       
    21 <p>Code example: </p>
       
    22 <p>First define a data structure for the event data:</p>
       
    23 <codeblock id="GUID-BBC9DCFA-F46C-4AC9-BC7F-B1A2DB39963A" xml:space="preserve">class TEventsEventType
       
    24     {
       
    25     public:
       
    26         // Event iData
       
    27         TBufC&lt; TWsEvent::EWsEventDataSize&gt; data;
       
    28         };
       
    29 </codeblock>
       
    30 <p>Then create an event and send it to all window groups:</p>
       
    31 <codeblock id="GUID-0E8CE3D4-19F2-46D6-9A22-9A7EBC73F5C5" xml:space="preserve">// Create a window server event
       
    32 TWsEvent event;
       
    33 TEventsEventType eventType;
       
    34 // Set event data. eventType.data = KData;
       
    35 event.SetType( ETestEvent1 ); // set event type
       
    36 event.SetTimeNow(); // set the event time
       
    37 event.SetHandle( iWsSession.WsHandle() ); // set window server handle
       
    38 *( TEventsEventType* )( event.EventData() ) = eventType; // set event data
       
    39 // Send the created event
       
    40 User::LeaveIfError( iWsSession.SendEventToAllWindowGroups( event ) );
       
    41 </codeblock>
       
    42 <p>Catch the event using the following method:</p>
       
    43 <codeblock id="GUID-1BF859E7-EC92-4BDA-AFCE-DEB82854C8D7" xml:space="preserve">void CEventsAppUi::HandleApplicationSpecificEventL(TInt aType,const TWsEvent&amp; aEvent)
       
    44     {
       
    45     // Check the event type
       
    46     if( aType == ETestEvent1 )
       
    47         {
       
    48         // Cast to TEventsEventType
       
    49         TEventsEventType event;
       
    50         event = *( TEventsEventType* )aEvent.EventData();
       
    51         // Print the data
       
    52         iEikonEnv-&gt;InfoMsg( event.data );
       
    53         }
       
    54         // Call the base class implementation
       
    55         CEikAppUi::HandleApplicationSpecificEventL( aType, aEvent );
       
    56     }
       
    57 </codeblock>
       
    58 </conbody></concept>