summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2012-05-30 19:19:58 +0300
committerAndrei Karas <akaras@inbox.ru>2012-05-30 19:19:58 +0300
commita8b1e41599fd1f18fccc8f34ddca2bca33c4bf4f (patch)
treec30c586086c1b9797a0b59a420dcdd68d71edb43 /src
parent4c1ecb78ef90c709acad9023cfd7a13e9f1a1814 (diff)
downloadplus-a8b1e41599fd1f18fccc8f34ddca2bca33c4bf4f.tar.gz
plus-a8b1e41599fd1f18fccc8f34ddca2bca33c4bf4f.tar.bz2
plus-a8b1e41599fd1f18fccc8f34ddca2bca33c4bf4f.tar.xz
plus-a8b1e41599fd1f18fccc8f34ddca2bca33c4bf4f.zip
Fix key handling conflict issue in login dialog.
Diffstat (limited to 'src')
-rw-r--r--src/gui/logindialog.cpp4
-rw-r--r--src/gui/widgets/textfield.cpp15
2 files changed, 17 insertions, 2 deletions
diff --git a/src/gui/logindialog.cpp b/src/gui/logindialog.cpp
index 63073e9d5..54be72a6e 100644
--- a/src/gui/logindialog.cpp
+++ b/src/gui/logindialog.cpp
@@ -314,8 +314,10 @@ void LoginDialog::action(const gcn::ActionEvent &event)
void LoginDialog::keyPressed(gcn::KeyEvent &keyEvent)
{
- int actionId = static_cast<KeyEvent*>(&keyEvent)->getActionId();
+ if (keyEvent.isConsumed())
+ return;
+ int actionId = static_cast<KeyEvent*>(&keyEvent)->getActionId();
if (actionId == Input::KEY_GUI_CANCEL)
{
action(gcn::ActionEvent(nullptr, mServerButton->getActionEventId()));
diff --git a/src/gui/widgets/textfield.cpp b/src/gui/widgets/textfield.cpp
index 99cc93fd1..4f8f0d093 100644
--- a/src/gui/widgets/textfield.cpp
+++ b/src/gui/widgets/textfield.cpp
@@ -206,6 +206,9 @@ void TextField::keyPressed(gcn::KeyEvent &keyEvent)
buf[1] = 0;
mText.insert(mCaretPosition, std::string(buf));
mCaretPosition += 1;
+ keyEvent.consume();
+ logger->log("TextField::keyPressed1");
+ return;
}
}
else if (!mMaximum || mText.size() < mMaximum)
@@ -233,6 +236,8 @@ void TextField::keyPressed(gcn::KeyEvent &keyEvent)
mText.insert(mCaretPosition, std::string(buf, buf + len));
mCaretPosition += len;
+ keyEvent.consume();
+ return;
}
}
@@ -362,6 +367,7 @@ void TextField::keyPressed(gcn::KeyEvent &keyEvent)
{
case Input::KEY_GUI_LEFT:
{
+ consumed = true;
while (mCaretPosition > 0)
{
--mCaretPosition;
@@ -373,6 +379,7 @@ void TextField::keyPressed(gcn::KeyEvent &keyEvent)
case Input::KEY_GUI_RIGHT:
{
+ consumed = true;
unsigned sz = static_cast<unsigned>(mText.size());
while (mCaretPosition < sz)
{
@@ -388,6 +395,7 @@ void TextField::keyPressed(gcn::KeyEvent &keyEvent)
case Input::KEY_GUI_DELETE:
{
+ consumed = true;
unsigned sz = static_cast<unsigned>(mText.size());
while (mCaretPosition < sz)
{
@@ -403,6 +411,7 @@ void TextField::keyPressed(gcn::KeyEvent &keyEvent)
}
case Input::KEY_GUI_BACKSPACE:
+ consumed = true;
deleteCharLeft(mText, &mCaretPosition);
break;
@@ -414,15 +423,18 @@ void TextField::keyPressed(gcn::KeyEvent &keyEvent)
case Input::KEY_GUI_HOME:
mCaretPosition = 0;
+ consumed = true;
break;
case Input::KEY_GUI_END:
mCaretPosition = static_cast<unsigned>(mText.size());
+ consumed = true;
break;
case Input::KEY_GUI_TAB:
if (mLoseFocusOnTab)
return;
+ consumed = true;
break;
default:
@@ -432,7 +444,8 @@ void TextField::keyPressed(gcn::KeyEvent &keyEvent)
if (mSendAlwaysEvents)
distributeActionEvent();
- keyEvent.consume();
+ if (consumed)
+ keyEvent.consume();
fixScroll();
}