Symbian3/SDK/Source/GUID-33D93E96-98A9-4116-9028-3241D76A1036.dita
changeset 7 51a74ef9ed63
child 8 ae94777fff8f
equal deleted inserted replaced
6:43e37759235e 7:51a74ef9ed63
       
     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-33D93E96-98A9-4116-9028-3241D76A1036" xml:lang="en"><title>Enabling
       
    13 additional touch events for your application</title><shortdesc>The Symbian platform provides additional touch events to enable
       
    14 drag events using <parmname>CCoeControl::EnableDragEvents()</parmname>and
       
    15 to specify screen areas for touch events.</shortdesc><prolog><metadata><keywords/></metadata></prolog><conbody>
       
    16 <p>By default, the Symbian platform sends only <parmname>EButton1Up</parmname> and <parmname>EButton1Down</parmname> touch
       
    17 events to applications.</p>
       
    18 <p>If you want to enable <parmname>EDrag</parmname> touch events, implement <parmname>CCoeControl::EnableDragEvents()</parmname> in
       
    19 your container class.</p>
       
    20 <p>When the mobile device user drags the stylus on the screen, <codeph>TPointerEvent::EDrag()</codeph> events
       
    21 are sent. When dragging stops, the application receives the event <codeph>TPointerEvent::EButton1Up()</codeph>.</p>
       
    22 <codeblock xml:space="preserve">void CTableauControl::ConstructL( const TRect&amp; aRect )
       
    23     {
       
    24     // This is parent window
       
    25     CreateWindowL();
       
    26 
       
    27     EnableDragEvents();
       
    28 
       
    29     //SetRect( aRect );
       
    30     SetExtentToWholeScreen();
       
    31     
       
    32     
       
    33     // Initialize component array
       
    34     InitComponentArrayL();
       
    35     
       
    36     
       
    37 	 //Implement your own logic here
       
    38   	 ActivateL();
       
    39     }</codeblock>
       
    40 <p>It is enough that the container control set <codeph>EnableDragEvents()</codeph> in
       
    41 its construction. <codeph>EnableDragEvents()</codeph> need not be set again
       
    42 for the child controls to receive dragging events.</p>
       
    43 <section id="GUID-7B30F0D5-1EAE-4F40-B04F-6A3953BCC634"><title>Controlling
       
    44 which control receives a touch event</title><p>Particularly when you are receiving
       
    45 drag events it may be that an object in the window may be drawn by one control,
       
    46 while the pointer is over another control. In cases where you want to ensure
       
    47 that pointer events are received by the intended control, implement <parmname>CCoeControl::SetPointerCapture()</parmname>.</p><p>When
       
    48 a control receives a <parmname>TPointerEvent::EButton1Down()</parmname> event,
       
    49 all events will be sent to this control until the next <parmname>TPointerEvent::EButton1Up()</parmname> event.
       
    50 If you want to have events to be sent to another control before the <parmname>TPointerEvent::EButton1Up()</parmname> event,
       
    51 call <codeph>SetPointerCapture(ETrue)</codeph> from the new control. </p><p>When
       
    52 the new control has received its pointer event and <parmname>TPointerEvent::EButton1Up()</parmname> has
       
    53 been received, you have to call <codeph>SetPointerCapture(EFalse)</codeph> from
       
    54 the new control to stop events being sent to it indefinitely.</p></section>
       
    55 <section id="GUID-8C337F8B-346A-430A-9A7A-A48B53031421"><title>Specifying
       
    56 screen areas for touch events</title><p>To specify screen areas (<codeph>TRect</codeph>)
       
    57 for touch events, see the example below.</p><codeblock xml:space="preserve">void CTableauControl::HandlePointerEventL(const TPointerEvent&amp; aPointerEvent)
       
    58     {
       
    59     // Does the user point exit text on screen? 
       
    60     // iExitRect is rectangle of the text area on screen.
       
    61     if (iExitRect.Contains(aPointerEvent.iPosition))
       
    62         {
       
    63         if (iEikonEnv-&gt;QueryWinL(_L("Klondike"),_L("Exit?")))
       
    64             {
       
    65             // Exit was pointed, then do exit   
       
    66             (static_cast&lt;CKlondikeAppUi*&gt;(iEikonEnv-&gt;AppUi()))-&gt;HandleCommandL(EEikCmdExit);
       
    67             return;
       
    68             }
       
    69         }
       
    70     ...
       
    71     }</codeblock></section>
       
    72 <section id="GUID-8B12AF1C-A98A-416D-A586-807CFC2B839D"><title>Ignoring events
       
    73 other than pointer up in your control</title><p>In cases where you want to
       
    74 make sure your control receives only touch <parmname>EButton1Up</parmname> events
       
    75 after receiving a touch <parmname>EButton1Down</parmname> event, implement <parmname>CCoeControl::IgnoreEventsUntilNextPointerUp()</parmname>. </p></section>
       
    76 </conbody></concept>