make ctrl+v works in lineEdits

This commit is contained in:
Eduardo Bart
2011-08-28 15:26:57 -03:00
parent ba8f8b889e
commit 65dca53c0f
5 changed files with 30 additions and 3 deletions

View File

@@ -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);

View File

@@ -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);