diff options
author | Andrei Karas <akaras@inbox.ru> | 2011-05-20 23:37:45 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2011-05-20 23:37:45 +0300 |
commit | 71d0606a0356e8f9a5fb605190aef7330b630b9e (patch) | |
tree | 6bc9a68a027f884b87a52747a7c86acedd8250e5 /src/gui/widgets/textfield.cpp | |
parent | 78ab801cc5dfe687718ec7e027c3050bed62a1e9 (diff) | |
download | mv-71d0606a0356e8f9a5fb605190aef7330b630b9e.tar.gz mv-71d0606a0356e8f9a5fb605190aef7330b630b9e.tar.bz2 mv-71d0606a0356e8f9a5fb605190aef7330b630b9e.tar.xz mv-71d0606a0356e8f9a5fb605190aef7330b630b9e.zip |
Possible fix for sticky paste key in X systems.
This code add 2 seconds timeout between paste actions.
Diffstat (limited to 'src/gui/widgets/textfield.cpp')
-rw-r--r-- | src/gui/widgets/textfield.cpp | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/src/gui/widgets/textfield.cpp b/src/gui/widgets/textfield.cpp index 8836b4ad4..8e61bce3c 100644 --- a/src/gui/widgets/textfield.cpp +++ b/src/gui/widgets/textfield.cpp @@ -49,7 +49,8 @@ TextField::TextField(const std::string &text, bool loseFocusOnTab, gcn::TextField(text), mNumeric(false), mMinimum(0), - mMaximum(0) + mMaximum(0), + mLastEventPaste(false) { setFrameSize(2); @@ -215,6 +216,10 @@ void TextField::keyPressed(gcn::KeyEvent &keyEvent) /* In UTF-8, 10xxxxxx is only used for inner parts of characters. So skip them when processing key presses. */ + // unblock past key + if (val != 22) + mLastEventPaste = 0; + switch (val) { case Key::LEFT: @@ -286,7 +291,11 @@ void TextField::keyPressed(gcn::KeyEvent &keyEvent) break; case 22: // Control code 22, SYNCHRONOUS IDLE, sent on Ctrl+v + // hack to prevent paste key sticking + if (mLastEventPaste && mLastEventPaste > cur_time) + break; handlePaste(); + mLastEventPaste = cur_time + 1; break; default: break; |