Symbian3/SDK/Source/GUID-62DF565C-8121-429F-99D0-B5FBDE634AA9.dita
author Dominic Pinkman <dominic.pinkman@nokia.com>
Tue, 20 Jul 2010 12:00:49 +0100
changeset 13 48780e181b38
parent 7 51a74ef9ed63
permissions -rw-r--r--
Week 28 contribution of SDK documentation content. See release notes for details. Fixes bugs Bug 1897 and Bug 1522.

<?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="jar:GUID-759FBC7F-5384-4487-8457-A8D4B76F6AA6.jar!/html/Touch_UI_Utilities_APIIndexPage.html" format="application/java-archive">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>