ModelPtr& model = impl.mModel;
LogicalModelPtr& logicalModel = model->mLogicalModel;
VisualModelPtr& visualModel = model->mVisualModel;
+ uint32_t oldSelStart = eventData.mLeftSelectionPosition;
+ uint32_t oldSelEnd = eventData.mRightSelectionPosition;
CharacterIndex& primaryCursorPosition = eventData.mPrimaryCursorPosition;
CharacterIndex previousPrimaryCursorPosition = primaryCursorPosition;
// Update selection position after moving the cursor
eventData.mLeftSelectionPosition = primaryCursorPosition;
eventData.mRightSelectionPosition = primaryCursorPosition;
+
+ if(impl.mSelectableControlInterface != nullptr && eventData.mDecorator->IsHighlightVisible())
+ {
+ impl.mSelectableControlInterface->SelectionChanged(oldSelStart, oldSelEnd, eventData.mLeftSelectionPosition, eventData.mRightSelectionPosition);
+ }
}
if(isShiftModifier && impl.IsShowingRealText() && eventData.mShiftSelectionFlag)
int cursorPositionDelta = primaryCursorPosition - previousPrimaryCursorPosition;
if(cursorPositionDelta > 0 || eventData.mRightSelectionPosition > 0u) // Check the boundary
{
- uint32_t oldStart = eventData.mLeftSelectionPosition;
- uint32_t oldEnd = eventData.mRightSelectionPosition;
-
eventData.mRightSelectionPosition += cursorPositionDelta;
+ eventData.mPrimaryCursorPosition = eventData.mRightSelectionPosition;
if(impl.mSelectableControlInterface != nullptr)
{
- impl.mSelectableControlInterface->SelectionChanged(oldStart, oldEnd, eventData.mLeftSelectionPosition, eventData.mRightSelectionPosition);
+ impl.mSelectableControlInterface->SelectionChanged(oldSelStart, oldSelEnd, eventData.mLeftSelectionPosition, eventData.mRightSelectionPosition);
}
}
- selecting = true;
+
+ if(impl.mSelectableControlInterface != nullptr && eventData.mLeftSelectionPosition == eventData.mRightSelectionPosition)
+ {
+ // If left selection position and right selection position are the same, the selection is canceled.
+ selecting = false;
+ }
+ else
+ {
+ selecting = true;
+ }
}
else if(eventData.mLeftSelectionPosition != eventData.mRightSelectionPosition)
{
eventData.mDecorator->SetPopupActive(false);
}
}
+ else
+ {
+ // If no selection, set a normal cursor.
+ impl.ChangeState(EventData::EDITING);
+ eventData.mUpdateCursorPosition = true;
+ }
}
else
{
if(impl.IsShowingRealText())
{
// Convert from control's coords to text's coords.
- const float xPosition = event.p2.mFloat - model->mScrollPosition.x;
- const float yPosition = event.p3.mFloat - model->mScrollPosition.y;
+ const float xPosition = event.p2.mFloat - model->mScrollPosition.x;
+ const float yPosition = event.p3.mFloat - model->mScrollPosition.y;
+ uint32_t oldSelStart = eventData.mLeftSelectionPosition;
+ uint32_t oldSelEnd = eventData.mRightSelectionPosition;
// Keep the tap 'x' position. Used to move the cursor.
eventData.mCursorHookPositionX = xPosition;
CharacterHitTest::TAP,
matchedCharacter);
+ if(impl.mSelectableControlInterface != nullptr && eventData.mDecorator->IsHighlightVisible())
+ {
+ impl.mSelectableControlInterface->SelectionChanged(oldSelStart, oldSelEnd, eventData.mPrimaryCursorPosition, eventData.mPrimaryCursorPosition);
+ }
+
// When the cursor position is changing, delay cursor blinking
eventData.mDecorator->DelayCursorBlink();
}
eventData.mLeftSelectionPosition = 0u;
eventData.mRightSelectionPosition = model->mLogicalModel->mText.Count();
+ eventData.mPrimaryCursorPosition = eventData.mRightSelectionPosition;
if(impl.mSelectableControlInterface != nullptr)
{
EventData& eventData = *impl.mEventData;
if(eventData.mSelectionEnabled && eventData.mState == EventData::SELECTING)
{
- eventData.mPrimaryCursorPosition = 0u;
- uint32_t oldStart = eventData.mLeftSelectionPosition;
- uint32_t oldEnd = eventData.mRightSelectionPosition;
+ uint32_t oldStart = eventData.mLeftSelectionPosition;
+ uint32_t oldEnd = eventData.mRightSelectionPosition;
eventData.mLeftSelectionPosition = eventData.mRightSelectionPosition = eventData.mPrimaryCursorPosition;
- impl.ChangeState(EventData::INACTIVE);
+ impl.ChangeState(EventData::EDITING);
eventData.mUpdateCursorPosition = true;
eventData.mUpdateInputStyle = true;
eventData.mScrollAfterUpdatePosition = true;
impl.mEventData->mLeftSelectionPosition = start;
impl.mEventData->mRightSelectionPosition = end;
+ impl.mEventData->mPrimaryCursorPosition = end;
if(impl.mSelectableControlInterface != nullptr)
{
eventData.mIsRightHandleSelected = true;
}
- if((impl.mSelectableControlInterface != nullptr) || eventData.mUpdateRightSelectionPosition || eventData.mUpdateLeftSelectionPosition)
+ if((impl.mSelectableControlInterface != nullptr) && ((oldStart != eventData.mLeftSelectionPosition) || (oldEnd != eventData.mRightSelectionPosition)))
{
impl.mSelectableControlInterface->SelectionChanged(oldStart, oldEnd, eventData.mLeftSelectionPosition, eventData.mRightSelectionPosition);
}
}
}
- if((impl.mSelectableControlInterface != nullptr) || eventData.mUpdateRightSelectionPosition || eventData.mUpdateLeftSelectionPosition)
+ if((impl.mSelectableControlInterface != nullptr) && ((oldStart != eventData.mLeftSelectionPosition) || (oldEnd != eventData.mRightSelectionPosition)))
{
impl.mSelectableControlInterface->SelectionChanged(oldStart, oldEnd, eventData.mLeftSelectionPosition, eventData.mRightSelectionPosition);
}