diff -r 2a26698d78ba -r 38529f706030 phoneuis/dialer/src/cdialerkeypadbutton.cpp --- a/phoneuis/dialer/src/cdialerkeypadbutton.cpp Mon Mar 15 12:40:24 2010 +0200 +++ b/phoneuis/dialer/src/cdialerkeypadbutton.cpp Wed Mar 31 21:30:06 2010 +0300 @@ -19,17 +19,17 @@ // INCLUDE FILES #include -#include +#include #include -#include -#include -#include -#include +#include +#include +#include +#include #include // for KDC_APP_RESOURCE_DIR #include #include #include -#include +#include #include "dialercommon.h" #include "dialertrace.h" @@ -52,6 +52,9 @@ static const TInt KCent = 100; +// Copied from CAknButton +const TInt KDragEventSensitivity = 1; + // --------------------------------------------------------------------------- // C++ default constructor // --------------------------------------------------------------------------- @@ -233,6 +236,49 @@ SetIconLayout( buttonRect ); } +// --------------------------------------------------------------------------- +// Pointer event handling. Implemented here just to detect when touch is +// dragged outside pressed button as no appropriate control event is sent +// by CAknButton when this happens. +// --------------------------------------------------------------------------- +// +void CDialerKeyPadButton::HandlePointerEventL( const TPointerEvent& aPointerEvent ) + { + // Do the check before forwarding events to base class as it will update + // iButtonPressed member variable used here. + // Own drag event counter has to be used. + // Logic here to determine whether pointer is dragged outside button is + // the same as used in CAknButton. + + if ( State() && IsVisible() ) + { + if ( aPointerEvent.iType == TPointerEvent::EButton1Down ) + { + iDragEventCounter = 0; + } + else if ( aPointerEvent.iType == TPointerEvent::EDrag ) + { + iDragEventCounter++; + if ( iDragEventCounter >= KDragEventSensitivity ) + { + iDragEventCounter = 0; + + TBool buttonEvent( Rect().Contains( aPointerEvent.iPosition ) ); + + // Pointer is dragged outside the pressed button area + if ( !buttonEvent && iButtonPressed && Observer() ) + { + Observer()->HandleControlEventL( this, + static_cast( + CDialerKeyPadButton::EEventDraggingOutsideButton ) ); + } + } + } + } + + CAknButton::HandlePointerEventL( aPointerEvent ); + } + // ----------------------------------------------------------------------------- // Gets the correct text color. // -----------------------------------------------------------------------------