textEditor.SetProperty( DevelTextEditor::Property::PRIMARY_CURSOR_POSITION, 3);
application.SendNotification();
application.Render();
+ textEditor.SetKeyInputFocus();
application.ProcessEvent( GenerateKey( "D", "", "D", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "D", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
textField.SetProperty( DevelTextField::Property::PRIMARY_CURSOR_POSITION, 3);
application.SendNotification();
application.Render();
+ textField.SetKeyInputFocus();
application.ProcessEvent( GenerateKey( "D", "", "D", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "D", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
{
uint32_t position = static_cast<uint32_t>(value.Get<int>());
DALI_LOG_INFO(gLogFilter, Debug::General, "TextEditor %p PRIMARY_CURSOR_POSITION %d\n", impl.mController.Get(), position);
- if(impl.mController->SetPrimaryCursorPosition(position))
+ if(impl.mController->SetPrimaryCursorPosition(position, impl.HasKeyInputFocus()))
{
impl.SetKeyInputFocus();
}
{
uint32_t position = static_cast<uint32_t>(value.Get<int>());
DALI_LOG_INFO(gLogFilter, Debug::General, "TextField %p PRIMARY_CURSOR_POSITION %d\n", impl.mController.Get(), position);
- if(impl.mController->SetPrimaryCursorPosition(position))
+ if(impl.mController->SetPrimaryCursorPosition(position, impl.HasKeyInputFocus()))
{
impl.SetKeyInputFocus();
}
return mEventData->mPrimaryCursorPosition;
}
-bool Controller::Impl::SetPrimaryCursorPosition(CharacterIndex index)
+bool Controller::Impl::SetPrimaryCursorPosition(CharacterIndex index, bool focused)
{
if(nullptr == mEventData)
{
uint32_t length = static_cast<uint32_t>(mModel->mLogicalModel->mText.Count());
mEventData->mPrimaryCursorPosition = std::min(index, length);
- ChangeState(EventData::EDITING);
- mEventData->mLeftSelectionPosition = mEventData->mRightSelectionPosition = mEventData->mPrimaryCursorPosition;
- mEventData->mUpdateCursorPosition = true;
- ScrollTextToMatchCursor();
+ // If there is no focus, only the value is updated.
+ if(focused)
+ {
+ ChangeState(EventData::EDITING);
+ mEventData->mLeftSelectionPosition = mEventData->mRightSelectionPosition = mEventData->mPrimaryCursorPosition;
+ mEventData->mUpdateCursorPosition = true;
+ ScrollTextToMatchCursor();
+ }
return true;
}
/**
* @copydoc Text::Controller::SetPrimaryCursorPosition()
*/
- bool SetPrimaryCursorPosition(CharacterIndex index);
+ bool SetPrimaryCursorPosition(CharacterIndex index, bool focused);
/**
* @copydoc Text::SelectableControlInterface::SetTextSelectionRange()
return mImpl->GetPrimaryCursorPosition();
}
-bool Controller::SetPrimaryCursorPosition(CharacterIndex index)
+bool Controller::SetPrimaryCursorPosition(CharacterIndex index, bool focused)
{
if(mImpl->mEventData)
{
mImpl->mEventData->mIsLeftHandleSelected = true;
mImpl->mEventData->mIsRightHandleSelected = true;
mImpl->mEventData->mCheckScrollAmount = true;
- if(mImpl->SetPrimaryCursorPosition(index))
+ if(mImpl->SetPrimaryCursorPosition(index, focused) && focused)
{
KeyboardFocusGainEvent();
return true;
* @brief Used to set the Primary cursor position.
*
* @param[in] index for the Primary cursor position.
+ * @param[in] focused true if UI control has gained focus to receive key event, false otherwise.
* @return[in] true if cursor position changed, false otherwise.
*/
- bool SetPrimaryCursorPosition(CharacterIndex index);
+ bool SetPrimaryCursorPosition(CharacterIndex index, bool focused);
/**
* @brief Creates a selection event.