Symbian3/SDK/Source/GUID-33D93E96-98A9-4116-9028-3241D76A1036.dita
author Dominic Pinkman <dominic.pinkman@nokia.com>
Fri, 11 Jun 2010 12:39:03 +0100
changeset 8 ae94777fff8f
parent 7 51a74ef9ed63
permissions -rw-r--r--
Week 23 contribution of SDK documentation content. See release notes for details. Fixes bugs Bug 2714, Bug 462.

<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright (c) 2007-2010 Nokia Corporation and/or its subsidiary(-ies) All rights reserved. -->
<!-- This component and the accompanying materials are made available under the terms of the License 
"Eclipse Public License v1.0" which accompanies this distribution, 
and is available at the URL "http://www.eclipse.org/legal/epl-v10.html". -->
<!-- Initial Contributors:
    Nokia Corporation - initial contribution.
Contributors: 
-->
<!DOCTYPE concept
  PUBLIC "-//OASIS//DTD DITA Concept//EN" "concept.dtd">
<concept id="GUID-33D93E96-98A9-4116-9028-3241D76A1036" xml:lang="en"><title>Enabling additional touch events for your application</title><shortdesc>The Symbian platform provides additional touch events to
enable drag events and to specify screen areas for touch events.</shortdesc><prolog><metadata><keywords/></metadata></prolog><conbody>
<p>By default, the Symbian platform sends only <parmname>EButton1Up</parmname> and <parmname>EButton1Down</parmname> touch events to applications.</p>
<p>If you want to enable <parmname>EDrag</parmname> touch events,
implement <xref href="GUID-B06F99BD-F032-3B87-AB26-5DD6EBE8C160.dita#GUID-B06F99BD-F032-3B87-AB26-5DD6EBE8C160/GUID-66B1D0C0-BFBB-36DB-BCC2-5563895251D5"><apiname>CCoeControl::EnableDragEvents()</apiname></xref> in your
container class.</p>
<p>When the mobile device user drags the stylus on the screen, <xref href="GUID-1FFA0073-3D83-388E-A824-08C31F90CC54.dita#GUID-1FFA0073-3D83-388E-A824-08C31F90CC54/GUID-5375D595-CF6A-38F6-9D62-E8DDF2D2BCF6"><apiname>TPointerEvent::EDrag()</apiname></xref> events are sent. When dragging stops,
the application receives the event <xref href="GUID-1FFA0073-3D83-388E-A824-08C31F90CC54.dita#GUID-1FFA0073-3D83-388E-A824-08C31F90CC54/GUID-5BADE607-E845-34B2-9C2D-B6882B7D4288"><apiname>TPointerEvent::EButton1Up()</apiname></xref>.</p>
<codeblock xml:space="preserve">void CTableauControl::ConstructL( const TRect&amp; aRect )
    {
    // This is parent window
    CreateWindowL();

    EnableDragEvents();

    SetRect( aRect );
    SetExtentToWholeScreen();
    
    
    // Initialize component array
    InitComponentArrayL();
    
    
	 //Implement your own logic here
  	 ActivateL();
    }</codeblock>
<p>It is enough that the container control set <codeph>EnableDragEvents()</codeph> in its construction. <codeph>EnableDragEvents()</codeph> need not
be set again for the child controls to receive dragging events.</p>
<section id="GUID-7B30F0D5-1EAE-4F40-B04F-6A3953BCC634"><title>Controlling
which control receives a touch event</title><p>Particularly when you
are receiving drag events it may be that an object in the window may
be drawn by one control, while the pointer is over another control.
In cases where you want to ensure that pointer events are received
by the intended control, implement <xref href="GUID-B06F99BD-F032-3B87-AB26-5DD6EBE8C160.dita#GUID-B06F99BD-F032-3B87-AB26-5DD6EBE8C160/GUID-172FDC09-7870-3FD0-9252-340178C58C28"><apiname>CCoeControl::SetPointerCapture()</apiname></xref>.</p><p>When a control receives a <xref href="GUID-1FFA0073-3D83-388E-A824-08C31F90CC54.dita#GUID-1FFA0073-3D83-388E-A824-08C31F90CC54/GUID-26CE2524-04BC-3592-A7E5-7EEC792A466E"><apiname>TPointerEvent::EButton1Down()</apiname></xref> event, all events will be sent to this control until the next <xref href="GUID-1FFA0073-3D83-388E-A824-08C31F90CC54.dita#GUID-1FFA0073-3D83-388E-A824-08C31F90CC54/GUID-5BADE607-E845-34B2-9C2D-B6882B7D4288"><apiname>TPointerEvent::EButton1Up()</apiname></xref> event. If you want to have
events to be sent to another control before the<xref href="GUID-1FFA0073-3D83-388E-A824-08C31F90CC54.dita#GUID-1FFA0073-3D83-388E-A824-08C31F90CC54/GUID-5BADE607-E845-34B2-9C2D-B6882B7D4288"><apiname>TPointerEvent::EButton1Up()</apiname></xref> event, call <codeph>SetPointerCapture(ETrue)</codeph> from the new
control. </p><p>When the new control has received its pointer event
and <xref href="GUID-1FFA0073-3D83-388E-A824-08C31F90CC54.dita#GUID-1FFA0073-3D83-388E-A824-08C31F90CC54/GUID-5BADE607-E845-34B2-9C2D-B6882B7D4288"><apiname>TPointerEvent::EButton1Up()</apiname></xref> has been received,
you have to call <codeph>SetPointerCapture(EFalse)</codeph> from the
new control to stop events being sent to it indefinitely.</p></section>
<section id="GUID-8C337F8B-346A-430A-9A7A-A48B53031421"><title>Specifying
screen areas for touch events</title><p>To specify screen areas (<codeph>TRect</codeph>) for touch events, see the example below.</p><codeblock xml:space="preserve">void CTableauControl::HandlePointerEventL(const TPointerEvent&amp; aPointerEvent)
    {
    // Does the user point exit text on screen? 
    // iExitRect is rectangle of the text area on screen.
    if (iExitRect.Contains(aPointerEvent.iPosition))
        {
        if (iEikonEnv-&gt;QueryWinL(_L("Klondike"),_L("Exit?")))
            {
            // Exit was pointed, then do exit   
            (static_cast&lt;CKlondikeAppUi*&gt;(iEikonEnv-&gt;AppUi()))-&gt;HandleCommandL(EEikCmdExit);
            return;
            }
        }
    ...
    }</codeblock></section>
<section id="GUID-8B12AF1C-A98A-416D-A586-807CFC2B839D"><title>Ignoring
events other than pointer up in your control</title><p>In cases where
you want to make sure your control receives only touch <parmname>EButton1Up</parmname> events after receiving a touch <parmname>EButton1Down</parmname> event, implement <xref href="GUID-B06F99BD-F032-3B87-AB26-5DD6EBE8C160.dita#GUID-B06F99BD-F032-3B87-AB26-5DD6EBE8C160/GUID-885AF2EB-587A-323B-99B5-019B2E7EBC78"><apiname>CCoeControl::IgnoreEventsUntilNextPointerUp()</apiname></xref>. </p></section>
</conbody></concept>