2 * Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies).
4 * This component and the accompanying materials are made available
5 * under the terms of "Eclipse Public License v1.0"
6 * which accompanies this distribution, and is available
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
9 * Initial Contributors:
10 * Nokia Corporation - initial contribution.
18 #ifndef AKNPOINTEREVENTSUPPRESSOR_H
19 #define AKNPOINTEREVENTSUPPRESSOR_H
27 * Utility class for removing unwanted pointer events, for instance
28 * when distinguishing tap events from intended drags.
30 * Usage pattern, where iSuppressor is a CAknPointerEventSuppressor*:
32 * void CMyControl::HandlePointerEventL(const TPointerEvent& aPointerEvent)
34 * if (iSuppressor->SuppressPointerEvent(aPointerEvent))
37 * switch (aPointerEvent.iType)
39 * case TPointerEvent::EButton1Down:
42 * case TPointerEvent::EButton1Up:
44 * HandleTapL(aPointerEvent);
46 * case TPointerEvent::EDrag:
48 * HandleDragL(aPointerEvent);
57 NONSHARABLE_CLASS(CAknPointerEventSuppressor) : public CBase
63 * This creates a pointer event suppressor that will suppress
64 * drag events while the pointer interaction may be a tap.
66 IMPORT_C static CAknPointerEventSuppressor* NewL();
70 IMPORT_C ~CAknPointerEventSuppressor();
73 * Tests whether a pointer event should be suppressed.
75 * A control that wants pointer event suppression should feed
76 * all pointer events to this function. It will return ETrue if
77 * the pointer event should be ignored by the control.
78 * Only controls that have unrelated behaviour on tap and drag
79 * actions need to use pointer event suppression.
81 * If this class is used to suppress drag events during a possible
82 * tap, and this function does not suppress a drag event, the
83 * client can be sure that a drag action is happening.
85 * @param aPointerEvent the pointer event which may need to be suppressed.
86 * @return ETrue if the pointer event should be suppressed, or EFalse if it should be handled.
88 IMPORT_C TBool SuppressPointerEvent(const TPointerEvent& aPointerEvent);
90 * Set the maximum time period that drag events should be
91 * ignored during a pointer interaction.
93 * @param aDuration the maximum duration of a tap action.
95 IMPORT_C void SetMaxTapDuration(TTimeIntervalMicroSeconds aDuration);
97 * Set the maximum pointer movement for which drag events
98 * should be ignored during a pointer interaction.
100 * @param aMoveLimits the pixel movement limits within which a touch action is considered a tap
102 IMPORT_C void SetMaxTapMove(TSize aMoveLimits);
104 * Set the minimum time between drag events.
105 * This can be used to reduce the frequency of drag event reception when
106 * events are not desired at maximum speed.
108 * @param aInterval the minimum interval between which drag events are wanted
110 IMPORT_C void SetMinInterDragInterval(TTimeIntervalMicroSeconds aInterval);
113 CAknPointerEventSuppressor();
116 TTimeIntervalMicroSeconds iMaxTapDuration;
118 TTimeIntervalMicroSeconds iMinInterDragInterval;
122 TTime iLastEventTime;