{
switch( iter->type )
{
- case Event::CURSOR_KEY_EVENT:
- {
- OnCursorKeyEvent( *iter );
- break;
- }
- case Event::TAP_EVENT:
- {
- OnTapEvent( *iter );
- break;
- }
- case Event::PAN_EVENT:
- {
- OnPanEvent( *iter );
- break;
- }
- case Event::GRAB_HANDLE_EVENT:
- case Event::LEFT_SELECTION_HANDLE_EVENT:
- case Event::RIGHT_SELECTION_HANDLE_EVENT: // Fall through
- {
- OnHandleEvent( *iter );
- break;
- }
+ case Event::CURSOR_KEY_EVENT:
+ {
+ OnCursorKeyEvent( *iter );
+ break;
+ }
+ case Event::TAP_EVENT:
+ {
+ OnTapEvent( *iter );
+ break;
+ }
+ case Event::PAN_EVENT:
+ {
+ OnPanEvent( *iter );
+ break;
+ }
+ case Event::GRAB_HANDLE_EVENT:
+ case Event::LEFT_SELECTION_HANDLE_EVENT:
+ case Event::RIGHT_SELECTION_HANDLE_EVENT: // Fall through
+ {
+ OnHandleEvent( *iter );
+ break;
+ }
+ case Event::SELECT:
+ {
+ OnSelectEvent( *iter );
+ break;
+ }
+ case Event::SELECT_ALL:
+ {
+ OnSelectAllEvent();
+ break;
+ }
}
}
}
+
// The cursor must also be repositioned after inserts into the model
if( mEventData->mUpdateCursorPosition )
{
mEventData->mUpdateCursorPosition = true;
mEventData->mScrollAfterUpdatePosition = true;
}
- else if( mEventData->mSelectionEnabled &&
- ( 2u == tapCount ) )
- {
- // The event.p2 and event.p3 are in decorator coords. Need to transforms to text coords.
- const float xPosition = event.p2.mFloat - mEventData->mScrollPosition.x - mAlignmentOffset.x;
- const float yPosition = event.p3.mFloat - mEventData->mScrollPosition.y - mAlignmentOffset.y;
-
- RepositionSelectionHandles( xPosition,
- yPosition );
-
- mEventData->mScrollAfterUpdatePosition = true;
- mEventData->mUpdateLeftSelectionPosition = true;
- mEventData->mUpdateRightSelectionPosition = true;
- }
}
}
} // end ( HANDLE_SCROLLING == state )
}
+void Controller::Impl::OnSelectEvent( const Event& event )
+{
+ if( NULL == mEventData )
+ {
+ // Nothing to do if there is no text.
+ return;
+ }
+
+ if( mEventData->mSelectionEnabled )
+ {
+ // The event.p2 and event.p3 are in decorator coords. Need to transforms to text coords.
+ const float xPosition = event.p2.mFloat - mEventData->mScrollPosition.x - mAlignmentOffset.x;
+ const float yPosition = event.p3.mFloat - mEventData->mScrollPosition.y - mAlignmentOffset.y;
+
+ RepositionSelectionHandles( xPosition,
+ yPosition );
+
+ mEventData->mScrollAfterUpdatePosition = true;
+ mEventData->mUpdateLeftSelectionPosition = true;
+ mEventData->mUpdateRightSelectionPosition = true;
+ }
+}
+
+void Controller::Impl::OnSelectAllEvent()
+{
+ if( NULL == mEventData )
+ {
+ // Nothing to do if there is no text.
+ return;
+ }
+
+ if( mEventData->mSelectionEnabled )
+ {
+ RepositionSelectionHandles( 0u,
+ mLogicalModel->mText.Count() );
+
+ mEventData->mScrollAfterUpdatePosition = true;
+ mEventData->mUpdateLeftSelectionPosition = true;
+ mEventData->mUpdateRightSelectionPosition = true;
+ }
+}
+
void Controller::Impl::RepositionSelectionHandles( CharacterIndex selectionStart, CharacterIndex selectionEnd )
{
if( selectionStart == selectionEnd )
PAN_EVENT,
GRAB_HANDLE_EVENT,
LEFT_SELECTION_HANDLE_EVENT,
- RIGHT_SELECTION_HANDLE_EVENT
+ RIGHT_SELECTION_HANDLE_EVENT,
+ SELECT,
+ SELECT_ALL
};
union Param
void OnHandleEvent( const Event& event );
+ void OnSelectEvent( const Event& event );
+
+ void OnSelectAllEvent();
+
void RepositionSelectionHandles( CharacterIndex selectionStart, CharacterIndex selectionEnd );
void RepositionSelectionHandles( float visualX, float visualY );
}
mImpl->ChangeState( EventData::EDITING );
+
+ // Handles & cursors must be repositioned after Relayout() i.e. after the Model has been updated
+ if( mImpl->mEventData )
+ {
+ Event event( Event::TAP_EVENT );
+ event.p1.mUint = tapCount;
+ event.p2.mFloat = x;
+ event.p3.mFloat = y;
+ mImpl->mEventData->mEventQueue.push_back( event );
+
+ mImpl->RequestRelayout();
+ }
}
else if( !isShowingPlaceholderText &&
mImpl->mEventData->mSelectionEnabled &&
( 2u == tapCount ) )
{
- if ( mImpl->mEventData->mState == EventData::SELECTING )
- {
- mImpl->ChangeState( EventData::SELECTION_CHANGED );
- }
- else
- {
- mImpl->ChangeState( EventData::SELECTING );
- }
+ SelectEvent( x, y, false );
}
}
- // Handles & cursors must be repositioned after Relayout() i.e. after the Model has been updated
- if( mImpl->mEventData )
- {
- Event event( Event::TAP_EVENT );
- event.p1.mUint = tapCount;
- event.p2.mFloat = x;
- event.p3.mFloat = y;
- mImpl->mEventData->mEventQueue.push_back( event );
-
- mImpl->RequestRelayout();
- }
-
// Reset keyboard as tap event has occurred.
mImpl->ResetImfManager();
}
}
}
+void Controller::SelectEvent( float x, float y, bool selectAll )
+{
+ if( mImpl->mEventData )
+ {
+ if ( mImpl->mEventData->mState == EventData::SELECTING )
+ {
+ mImpl->ChangeState( EventData::SELECTION_CHANGED );
+ }
+ else
+ {
+ mImpl->ChangeState( EventData::SELECTING );
+ }
+
+ if( selectAll )
+ {
+ Event event( Event::SELECT_ALL );
+ mImpl->mEventData->mEventQueue.push_back( event );
+ }
+ else
+ {
+ Event event( Event::SELECT );
+ event.p2.mFloat = x;
+ event.p3.mFloat = y;
+ mImpl->mEventData->mEventQueue.push_back( event );
+ }
+
+ mImpl->RequestRelayout();
+ }
+}
+
void Controller::GetTargetSize( Vector2& targetSize )
{
targetSize = mImpl->mControlSize;
void Controller::TextPopupButtonTouched( Dali::Toolkit::TextSelectionPopup::Buttons button )
{
+ if( NULL == mImpl->mEventData )
+ {
+ return;
+ }
+
+ switch( button )
+ {
+ case Toolkit::TextSelectionPopup::CUT:
+ {
+ break;
+ }
+ case Toolkit::TextSelectionPopup::COPY:
+ {
+ break;
+ }
+ case Toolkit::TextSelectionPopup::PASTE:
+ {
+ break;
+ }
+ case Toolkit::TextSelectionPopup::SELECT:
+ {
+ const Vector2& currentCursorPosition = mImpl->mEventData->mDecorator->GetPosition( PRIMARY_CURSOR );
+
+ if( mImpl->mEventData->mSelectionEnabled )
+ {
+ // Creates a SELECT event.
+ SelectEvent( currentCursorPosition.x, currentCursorPosition.y, false );
+ }
+ break;
+ }
+ case Toolkit::TextSelectionPopup::SELECT_ALL:
+ {
+ // Creates a SELECT_ALL event
+ SelectEvent( 0.f, 0.f, true );
+ break;
+ }
+ case Toolkit::TextSelectionPopup::CLIPBOARD:
+ {
+ break;
+ }
+ case Toolkit::TextSelectionPopup::NONE:
+ {
+ // Nothing to do.
+ break;
+ }
+ }
}
ImfManager::ImfCallbackData Controller::OnImfEvent( ImfManager& imfManager, const ImfManager::ImfEventData& imfEvent )
// Text-input Event Queuing
/**
- * @brief Caller by editable UI controls when keyboard focus is gained.
+ * @brief Called by editable UI controls when keyboard focus is gained.
*/
void KeyboardFocusGainEvent();
/**
- * @brief Caller by editable UI controls when focus is lost.
+ * @brief Called by editable UI controls when focus is lost.
*/
void KeyboardFocusLostEvent();
/**
- * @brief Caller by editable UI controls when key events are received.
+ * @brief Called by editable UI controls when key events are received.
*
* @param[in] event The key event.
* @param[in] type Used to distinguish between regular key events and IMF events.
bool KeyEvent( const Dali::KeyEvent& event );
/**
- * @brief Caller by editable UI controls when key events are received.
+ * @brief Called by editable UI controls when key events are received.
*
* @param[in] text The text to insert.
* @param[in] type Used to distinguish between regular key events and IMF events.
void InsertText( const std::string& text, InsertType type );
/**
- * @brief Caller by editable UI controls when a tap gesture occurs.
+ * @brief Called by editable UI controls when a tap gesture occurs.
* @param[in] tapCount The number of taps.
* @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 TapEvent( unsigned int tapCount, float x, float y );
/**
- * @brief Caller by editable UI controls when a pan gesture occurs.
+ * @brief Called by editable UI controls when a pan gesture occurs.
*
* @param[in] state The state of the gesture.
* @param[in] displacement This distance panned since the last pan gesture.
void PanEvent( Gesture::State state, const Vector2& displacement );
/**
+ * @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.
+ *
+ * @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.
+ * @param[in] selectAll Whether the whole text is selected.
+ */
+ void SelectEvent( float x, float y, bool selectAll );
+
+ /**
* @brief Event received from IMF manager
*
* @param[in] imfManager The IMF manager.