return false;
}
+ unsigned int oldPos = eventData->mPrimaryCursorPosition;
+
if(eventData->mDecorator)
{
for(std::vector<Event>::iterator iter = eventData->mEventQueue.begin();
OnSelectNoneEvent(impl);
break;
}
+ case Event::SELECT_RANGE:
+ {
+ OnSelectRangeEvent(impl, *iter);
+ break;
+ }
}
}
}
{
// Updates the cursor position and scrolls the text to make it visible.
CursorInfo cursorInfo;
+
// Calculate the cursor position from the new cursor index.
impl.GetCursorPosition(eventData->mPrimaryCursorPosition, cursorInfo);
- if(nullptr != impl.mEditableControlInterface)
+ //only emit the event if the cursor is moved in current function.
+ if(nullptr != impl.mEditableControlInterface && eventData->mEventQueue.size() > 0)
{
- impl.mEditableControlInterface->CursorMoved(eventData->mPrimaryCursorPosition);
+ impl.mEditableControlInterface->CursorPositionChanged(oldPos, eventData->mPrimaryCursorPosition);
}
if(eventData->mUpdateCursorHookPosition)
const LineRun& line = *(visualModel->mLines.Begin() + previousLineIndex);
// Get the next hit 'y' point.
- const float hitPointY = cursorInfo.lineOffset - 0.5f * (line.ascender - line.descender);
+ const float hitPointY = cursorInfo.lineOffset - 0.5f * GetLineHeight(line);
// Use the cursor hook position 'x' and the next hit 'y' position to calculate the new cursor index.
bool matchedCharacter = false;
const LineRun& line = *(visualModel->mLines.Begin() + lineIndex + 1u);
// Get the next hit 'y' point.
- const float hitPointY = cursorInfo.lineOffset + cursorInfo.lineHeight + 0.5f * (line.ascender - line.descender);
+ const float hitPointY = cursorInfo.lineOffset + cursorInfo.lineHeight + 0.5f * GetLineHeight(line);
// Use the cursor hook position 'x' and the next hit 'y' position to calculate the new cursor index.
bool matchedCharacter = false;
if(impl.mEventData)
{
EventData& eventData = *impl.mEventData;
- if(eventData.mSelectionEnabled)
+ if(eventData.mSelectionEnabled && eventData.mState != EventData::INACTIVE)
{
ModelPtr& model = impl.mModel;
const Vector2& scrollPosition = model->mScrollPosition;
}
}
+void ControllerImplEventHandler::OnSelectRangeEvent(Controller::Impl& impl, const Event& event)
+{
+ if(impl.mEventData && impl.mEventData->mSelectionEnabled && impl.mEventData->mState != EventData::INACTIVE)
+ {
+ ModelPtr& model = impl.mModel;
+ const Vector2& scrollPosition = model->mScrollPosition;
+
+ // Calculate the selection index.
+ const uint32_t length = static_cast<uint32_t>(model->mLogicalModel->mText.Count());
+ const uint32_t start = std::min(event.p2.mUint, length);
+ const uint32_t end = std::min(event.p3.mUint, length);
+
+ if(start != end)
+ {
+ // Calculates the logical position from the x,y coords.
+ impl.RepositionSelectionHandles(0.f - scrollPosition.x, 0.f - scrollPosition.y, Controller::NoTextTap::HIGHLIGHT);
+
+ impl.mEventData->mLeftSelectionPosition = start;
+ impl.mEventData->mRightSelectionPosition = end;
+ }
+ }
+}
+
void ControllerImplEventHandler::OnHandlePressed(Controller::Impl& impl, const Event& event, const bool isSmoothHandlePanEnabled)
{
ModelPtr& model = impl.mModel;