summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-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();
}