Symbian3/SDK/Source/GUID-62DF565C-8121-429F-99D0-B5FBDE634AA9.dita
changeset 7 51a74ef9ed63
child 13 48780e181b38
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-62DF565C-8121-429F-99D0-B5FBDE634AA9" xml:lang="en"><title>Using
       
    13 long-tap events</title><prolog><metadata><keywords/></metadata></prolog><conbody>
       
    14 <p>Long-tap events allow you to specify functions performed when the user
       
    15 taps and holds the button for a specified period of time. An example of a
       
    16 long-tap function is fast forwarding in a media player application by tapping
       
    17 and holding down a button.</p>
       
    18 <p>To receive long-tap events, use the class <xref href="jar:GUID-759FBC7F-5384-4487-8457-A8D4B76F6AA6.jar!/html/classCAknLongTapDetector.html" format="application/java-archive"><codeph>CAknLongTapDetector</codeph></xref> in the <xref href="GUID-92018B6B-3CBB-434D-9E61-F271C67E98E3.dita">Touch
       
    19 UI utilities API</xref>.</p>
       
    20 <p>To enable the handling of long tap events in your <codeph>CAknButton</codeph> ,
       
    21 set the flag <codeph>KAknButtonReportOnLongPress</codeph> for the button.
       
    22 When the long tap event starts,<codeph>CAknButton::ELongPressEvent()</codeph> is
       
    23 reported to the button observer (<codeph>MCoeControlObserver</codeph>). When
       
    24 the long tap event ends, <codeph>CAknButton::ELongPressEndedEvent()</codeph> is
       
    25 reported.</p>
       
    26 <p>To define the period for which the button needs to be held down for a long-tap
       
    27 event, use the method <xref href="jar:GUID-759FBC7F-5384-4487-8457-A8D4B76F6AA6.jar!/html/classCAknButton.html#5b5323936073f454e96847337131030a" format="application/java-archive"><codeph>SetLongPressInterval()</codeph></xref> in the class <xref href="jar:GUID-759FBC7F-5384-4487-8457-A8D4B76F6AA6.jar!/html/classCAknButton.html" format="application/java-archive"><codeph>CAknButton</codeph></xref>.</p>
       
    28 <codeblock xml:space="preserve">void CMyAppContainer::ConstructL() 
       
    29 { 
       
    30
       
    31 iButton = CAknButton::NewL( NULL, NULL, NULL, NULL, 
       
    32 
       
    33 KNullDesC, KNullDesC , KAknButtonReportOnLongPress, 0 ); 
       
    34 
       
    35 iButton-&gt;SetContainerWindowL( *this ); 
       
    36 iButton-&gt;SetObserver( this ); 
       
    37
       
    38 } 
       
    39 
       
    40 void CMyAppContainer::HandleControlEventL( CCoeControl* aControl, 
       
    41                                                   TCoeEvent aEventType ) 
       
    42     { 
       
    43         switch ( aEventType ) 
       
    44             { 
       
    45 
       
    46 // Button is pressed for a long time 
       
    47 
       
    48             case CAknButton::ELongPressEvent: 
       
    49                         if ( aControl == iButton ) 
       
    50 
       
    51 { 
       
    52 
       
    53
       
    54 
       
    55 } 
       
    56 
       
    57                 break; 
       
    58 
       
    59 // Button long press ended 
       
    60 
       
    61             case CAknButton::ELongPressEndedEvent: 
       
    62                         if ( aControl == iButton ) 
       
    63 
       
    64 { 
       
    65 
       
    66
       
    67 
       
    68 } 
       
    69 
       
    70                 break; 
       
    71 
       
    72             default: 
       
    73                 break; 
       
    74             } 
       
    75     } 
       
    76 
       
    77 </codeblock>
       
    78 </conbody></concept>