From: Adeel Kazmi Date: Wed, 1 Jul 2015 18:13:34 +0000 (-0700) Subject: Merge "Show CopyPaste Poup on long press" into devel/master X-Git-Tag: dali_1.0.48~20 X-Git-Url: http://review.tizen.org/git/?p=platform%2Fcore%2Fuifw%2Fdali-toolkit.git;a=commitdiff_plain;h=079795bcb6a8aab48e5e4252a86f524e6749fcbb;hp=394b478479627e640973168935bc0045c584b752 Merge "Show CopyPaste Poup on long press" into devel/master --- diff --git a/dali-toolkit/internal/controls/text-controls/text-field-impl.cpp b/dali-toolkit/internal/controls/text-controls/text-field-impl.cpp index fbe2fd5..30999da 100644 --- a/dali-toolkit/internal/controls/text-controls/text-field-impl.cpp +++ b/dali-toolkit/internal/controls/text-controls/text-field-impl.cpp @@ -881,9 +881,8 @@ void TextField::OnInitialize() mController->EnableTextInput( mDecorator ); // Forward input events to controller - EnableGestureDetection(Gesture::Tap); + EnableGestureDetection( static_cast( Gesture::Tap | Gesture::Pan |Gesture::LongPress ) ); GetTapGestureDetector().SetMaximumTapsRequired( 2 ); - EnableGestureDetection(Gesture::Pan); self.TouchedSignal().Connect( this, &TextField::OnTouched ); @@ -1069,6 +1068,11 @@ void TextField::OnPan( const PanGesture& gesture ) mController->PanEvent( gesture.state, gesture.displacement ); } +void TextField::OnLongPress( const LongPressGesture& gesture ) +{ + mController->LongPressEvent( gesture.state, gesture.localPoint.x, gesture.localPoint.y ); +} + bool TextField::OnKeyEvent( const KeyEvent& event ) { DALI_LOG_INFO( gLogFilter, Debug::Verbose, "TextField::OnKeyEvent %p keyCode %d\n", mController.Get(), event.keyCode ); diff --git a/dali-toolkit/internal/controls/text-controls/text-field-impl.h b/dali-toolkit/internal/controls/text-controls/text-field-impl.h index eb35b4f..2c32e3d 100644 --- a/dali-toolkit/internal/controls/text-controls/text-field-impl.h +++ b/dali-toolkit/internal/controls/text-controls/text-field-impl.h @@ -140,6 +140,11 @@ private: // From Control virtual void OnPan( const PanGesture& gesture ); /** + * @copydoc Control::OnLongPress() + */ + virtual void OnLongPress( const LongPressGesture& gesture ); + + /** * @copydoc Control::OnStageConnection() */ virtual void OnStageConnection( unsigned int depth ); diff --git a/dali-toolkit/internal/text/text-controller-impl.cpp b/dali-toolkit/internal/text/text-controller-impl.cpp index 0c6b2b7..9e29628 100644 --- a/dali-toolkit/internal/text/text-controller-impl.cpp +++ b/dali-toolkit/internal/text/text-controller-impl.cpp @@ -171,6 +171,11 @@ bool Controller::Impl::ProcessInputEvents() OnTapEvent( *iter ); break; } + case Event::LONG_PRESS_EVENT: + { + OnLongPressEvent( *iter ); + break; + } case Event::PAN_EVENT: { OnPanEvent( *iter ); @@ -539,6 +544,15 @@ void Controller::Impl::OnPanEvent( const Event& event ) } } +void Controller::Impl::OnLongPressEvent( const Event& event ) +{ + if ( EventData::EDITING == mEventData->mState ) + { + ChangeState ( EventData::EDITING_WITH_POPUP ); + mEventData->mDecoratorUpdated = true; + } +} + void Controller::Impl::OnHandleEvent( const Event& event ) { if( NULL == mEventData ) @@ -998,7 +1012,10 @@ void Controller::Impl::SetPopupButtons() } else if ( EventData::EDITING_WITH_POPUP == mEventData->mState ) { - buttonsToShow = TextSelectionPopup::Buttons( TextSelectionPopup::SELECT | TextSelectionPopup::SELECT_ALL ); + if ( mLogicalModel->mText.Count() && !IsShowingPlaceholderText()) + { + buttonsToShow = TextSelectionPopup::Buttons( TextSelectionPopup::SELECT | TextSelectionPopup::SELECT_ALL ); + } if ( !IsClipboardEmpty() ) { diff --git a/dali-toolkit/internal/text/text-controller-impl.h b/dali-toolkit/internal/text/text-controller-impl.h index 24b10e8..c630d9e 100644 --- a/dali-toolkit/internal/text/text-controller-impl.h +++ b/dali-toolkit/internal/text/text-controller-impl.h @@ -46,6 +46,7 @@ struct Event CURSOR_KEY_EVENT, TAP_EVENT, PAN_EVENT, + LONG_PRESS_EVENT, GRAB_HANDLE_EVENT, LEFT_SELECTION_HANDLE_EVENT, RIGHT_SELECTION_HANDLE_EVENT, @@ -334,6 +335,8 @@ struct Controller::Impl void OnPanEvent( const Event& event ); + void OnLongPressEvent( const Event& event ); + void OnHandleEvent( const Event& event ); void OnSelectEvent( const Event& event ); diff --git a/dali-toolkit/internal/text/text-controller.cpp b/dali-toolkit/internal/text/text-controller.cpp index fc372af..4e69a4e 100644 --- a/dali-toolkit/internal/text/text-controller.cpp +++ b/dali-toolkit/internal/text/text-controller.cpp @@ -1393,6 +1393,26 @@ void Controller::PanEvent( Gesture::State state, const Vector2& displacement ) } } +void Controller::LongPressEvent( Gesture::State state, float x, float y ) +{ + DALI_ASSERT_DEBUG( mImpl->mEventData && "Unexpected PanEvent" ); + + if ( mImpl->IsShowingPlaceholderText() || mImpl->mLogicalModel->mText.Count() == 0u ) + { + if ( mImpl->mEventData ) + { + Event event( Event::LONG_PRESS_EVENT ); + event.p1.mInt = state; + mImpl->mEventData->mEventQueue.push_back( event ); + mImpl->RequestRelayout(); + } + } + else if( mImpl->mEventData ) + { + SelectEvent( x, y, false ); + } +} + void Controller::SelectEvent( float x, float y, bool selectAll ) { if( mImpl->mEventData ) diff --git a/dali-toolkit/internal/text/text-controller.h b/dali-toolkit/internal/text/text-controller.h index dfeffdc..42ab96a 100644 --- a/dali-toolkit/internal/text/text-controller.h +++ b/dali-toolkit/internal/text/text-controller.h @@ -525,6 +525,15 @@ public: void PanEvent( Gesture::State state, const Vector2& displacement ); /** + * @brief Called by editable UI controls when a long press gesture occurs. + * + * @param[in] state The state of the gesture. + * @param[in] x The x position relative to the top-left of the parent control. + * @param[in] y The y position relative to the top-left of the parent control. + */ + void LongPressEvent( Gesture::State state, float x, float y ); + + /** * @brief Creates a selection event. * * It could be called from the TapEvent (double tap) or when the text selection popup's sellect all button is pressed.