__pTextString->GetCharAt(firstTextIndex+textLength - 1, ch);
if (ch == L'\n')
{
- SetCursorPosition(firstTextIndex+textLength - 1);
+ if (textLength == 0)
+ {
+ SetCursorPosition(firstTextIndex);
+ }
+ else
+ {
+ SetCursorPosition(firstTextIndex+textLength - 1);
+ }
}
else
{
return false;
}
-bool
-_EditPresenter::TranslateKeyEventInfo(const _Control& source, _KeyInfo& keyInfo)
-{
- _KeyCode keyCode = keyInfo.GetKeyCode();
- if (keyInfo.GetKeyModifier() & _KEY_MODIFIER_SHIFT || keyInfo.GetKeyModifier() & _KEY_MODIFIER_CTRL)
- {
- return false;
- }
- if ((keyInfo.GetKeyModifier() & _KEY_LOCK_NUM) && ((_KEY_NUMPAD_8 == keyCode || _KEY_NUMPAD_2 == keyCode || _KEY_NUMPAD_6 == keyCode || _KEY_NUMPAD_4 == keyCode)))
- {
- return false;
- }
- if (__isUSBKeyboardConnected && (_KEY_UP == keyCode || _KEY_NUMPAD_8 == keyCode || _KEY_DOWN == keyCode || _KEY_NUMPAD_2 == keyCode
- || _KEY_RIGHT == keyCode || _KEY_NUMPAD_6 == keyCode || _KEY_LEFT == keyCode || _KEY_NUMPAD_4 == keyCode || _KEY_ENTER == keyCode))
- {
- if (__isCopyPasteManagerExist)
- {
- InitializeCopyPasteManager();
- }
-
- FinishTextComposition();
-
- int curCursorLine = __pTextObject->GetLineIndexAtTextIndex(__pTextObject->GetCursorIndex());
- int totalLine = __pTextObject->GetTotalLineCount();
- if(_KEY_UP == keyCode || _KEY_NUMPAD_8 == keyCode)
- {
- if (curCursorLine == 0 || GetTextLength() == 0)
- {
- keyInfo.SetKeyCode(_KEY_TAB);
- keyInfo.SetKeyModifier(KEY_MODIFIER_SHIFT);
- }
- }
- else if ( _KEY_DOWN == keyCode || _KEY_NUMPAD_2 == keyCode)
- {
- if (curCursorLine == (totalLine - 1))
- {
- keyInfo.SetKeyCode(_KEY_TAB);
- }
- }
- else if (_KEY_RIGHT == keyCode || _KEY_NUMPAD_6 == keyCode)
- {
- if (__cursorPos == GetTextLength())
- {
- keyInfo.SetKeyCode(_KEY_TAB);
- }
- }
- else if (_KEY_LEFT == keyCode || _KEY_NUMPAD_4 == keyCode)
- {
- if (__cursorPos == 0)
- {
- keyInfo.SetKeyCode(_KEY_TAB);
- keyInfo.SetKeyModifier(KEY_MODIFIER_SHIFT);
- }
- }
- else if (_KEY_ENTER == keyCode)
- {
- if(__pEdit->GetEditStyle() & EDIT_STYLE_SINGLE_LINE)
- {
- keyInfo.SetKeyCode(_KEY_TAB);
- }
- }
- }
- return false;
-}
-
void
_EditPresenter::OnClipboardPopupClosed(const ClipboardItem* pClipboardItem)
{
ReplaceTextIntoPasswordHyphenString();
+ ScrollPanelToCursorPosition();
+
__pEdit->SendTextEvent(CORE_TEXT_EVENT_CHANGED);
return r;
int textLength = __pTextObject->GetTextLengthAt(curCursorLine-1);
if (offset > textLength)
{
- start = firstTextIndex+textLength;
+ start = firstTextIndex+textLength-1;
}
SetBlockRange(start, end);
}
int textLength = __pTextObject->GetTextLengthAt(curCursorLine-1);
if (offset > textLength)
{
- start = firstTextIndex+textLength;
+ start = firstTextIndex+textLength -1;
}
end = __cursorPos;
SetBlockRange(start, end);