Show CopyPaste Poup on long press 86/42686/6
authorAgnelo Vaz <agnelo.vaz@samsung.com>
Wed, 1 Jul 2015 12:44:37 +0000 (13:44 +0100)
committerAgnelo Vaz <agnelo.vaz@samsung.com>
Wed, 1 Jul 2015 16:32:09 +0000 (17:32 +0100)
Change-Id: Ie57064747fd5df6827bc1cd6b0770acc9085d2fe
Signed-off-by: Agnelo Vaz <agnelo.vaz@samsung.com>
dali-toolkit/internal/controls/text-controls/text-field-impl.cpp
dali-toolkit/internal/controls/text-controls/text-field-impl.h
dali-toolkit/internal/text/text-controller-impl.cpp
dali-toolkit/internal/text/text-controller-impl.h
dali-toolkit/internal/text/text-controller.cpp
dali-toolkit/internal/text/text-controller.h

index fbe2fd5..30999da 100644 (file)
@@ -881,9 +881,8 @@ void TextField::OnInitialize()
   mController->EnableTextInput( mDecorator );
 
   // Forward input events to controller
-  EnableGestureDetection(Gesture::Tap);
+  EnableGestureDetection( static_cast<Gesture::Type>( 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 );
index eb35b4f..2c32e3d 100644 (file)
@@ -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 );
index 5dc17a4..ecb5c54 100644 (file)
@@ -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() )
     {
index 24b10e8..c630d9e 100644 (file)
@@ -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 );
index fc372af..4e69a4e 100644 (file)
@@ -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 )
index dfeffdc..42ab96a 100644 (file)
@@ -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.