mirror of
https://github.com/edubart/otclient.git
synced 2025-10-20 06:23:26 +02:00
make ctrl+v works in lineEdits
This commit is contained in:
@@ -274,8 +274,27 @@ void UILineEdit::setCursorEnabled(bool enable)
|
||||
update();
|
||||
}
|
||||
|
||||
void UILineEdit::appendText(std::string text)
|
||||
{
|
||||
if(m_cursorPos >= 0) {
|
||||
// replace characters that are now allowed
|
||||
boost::replace_all(text, "\n", "");
|
||||
boost::replace_all(text, "\r", " ");
|
||||
|
||||
if(text.length() > 0) {
|
||||
m_text.insert(m_cursorPos, text);
|
||||
m_cursorPos += text.length();
|
||||
blinkCursor();
|
||||
update();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void UILineEdit::appendCharacter(char c)
|
||||
{
|
||||
if(c == '\n' || c == '\r')
|
||||
return;
|
||||
|
||||
if(m_cursorPos >= 0) {
|
||||
std::string tmp;
|
||||
tmp = c;
|
||||
@@ -384,6 +403,8 @@ bool UILineEdit::onKeyPress(uchar keyCode, char keyChar, int keyboardModifiers)
|
||||
setCursorPos(0);
|
||||
else if(keyCode == KC_END) // move cursor to last character
|
||||
setCursorPos(m_text.length());
|
||||
else if(keyCode == KC_V && keyboardModifiers == Fw::KeyboardCtrlModifier)
|
||||
appendText(g_platform.getClipboardText());
|
||||
else if(keyCode == KC_TAB) {
|
||||
if(UIWidgetPtr parent = getParent())
|
||||
parent->focusNextChild(Fw::TabFocusReason);
|
||||
|
@@ -41,6 +41,7 @@ public:
|
||||
|
||||
void clearText() { setText(""); }
|
||||
void moveCursor(bool right);
|
||||
void appendText(std::string text);
|
||||
void appendCharacter(char c);
|
||||
void removeCharacter(bool right);
|
||||
|
||||
|
Reference in New Issue
Block a user