Symbian3/PDK/Source/GUID-62DF565C-8121-429F-99D0-B5FBDE634AA9.dita
author Dominic Pinkman <Dominic.Pinkman@Nokia.com>
Tue, 30 Mar 2010 11:56:28 +0100
changeset 5 f345bda72bc4
parent 3 46218c8b8afa
child 12 80ef3a206772
permissions -rw-r--r--
Week 12 contribution of PDK documentation_content. See release notes for details. Fixes Bug 2054, Bug 1583, Bug 381, Bug 390, Bug 463, Bug 1897, Bug 344, Bug 1319, Bug 394, Bug 1520, Bug 1522, Bug 1892"

<?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-62DF565C-8121-429F-99D0-B5FBDE634AA9" xml:lang="en"><title>Using
long-tap events</title><prolog><metadata><keywords/></metadata></prolog><conbody>
<p>Long-tap events allow you to specify functions performed when the user
taps and holds the button for a specified period of time. An example of a
long-tap function is fast forwarding in a media player application by tapping
and holding down a button.</p>
<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
UI utilities API</xref>.</p>
<p>To enable the handling of long tap events in your <codeph>CAknButton</codeph> ,
set the flag <codeph>KAknButtonReportOnLongPress</codeph> for the button.
When the long tap event starts,<codeph>CAknButton::ELongPressEvent()</codeph> is
reported to the button observer (<codeph>MCoeControlObserver</codeph>). When
the long tap event ends, <codeph>CAknButton::ELongPressEndedEvent()</codeph> is
reported.</p>
<p>To define the period for which the button needs to be held down for a long-tap
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>
<codeblock xml:space="preserve">void CMyAppContainer::ConstructL() 
{ 

iButton = CAknButton::NewL( NULL, NULL, NULL, NULL, 

KNullDesC, KNullDesC , KAknButtonReportOnLongPress, 0 ); 

iButton-&gt;SetContainerWindowL( *this ); 
iButton-&gt;SetObserver( this ); 

} 

void CMyAppContainer::HandleControlEventL( CCoeControl* aControl, 
                                                  TCoeEvent aEventType ) 
    { 
        switch ( aEventType ) 
            { 

// Button is pressed for a long time 

            case CAknButton::ELongPressEvent: 
                        if ( aControl == iButton ) 

{ 



} 

                break; 

// Button long press ended 

            case CAknButton::ELongPressEndedEvent: 
                        if ( aControl == iButton ) 

{ 



} 

                break; 

            default: 
                break; 
            } 
    } 

</codeblock>
</conbody></concept>