diff --git a/src/gui/control/card_editor.cpp b/src/gui/control/card_editor.cpp index b40876da..407e3967 100644 --- a/src/gui/control/card_editor.cpp +++ b/src/gui/control/card_editor.cpp @@ -453,7 +453,11 @@ void DataEditor::onChar(wxKeyEvent& ev) { GetParent()->HandleWindowEvent(evt); } } else if (current_editor) { - current_editor->onChar(ev); + if (!current_editor->onChar(ev)) { + ev.Skip(); + } + } else { + ev.Skip(); } } diff --git a/src/gui/value/editor.hpp b/src/gui/value/editor.hpp index 0f0dddd0..4be9a38c 100644 --- a/src/gui/value/editor.hpp +++ b/src/gui/value/editor.hpp @@ -50,7 +50,7 @@ public: virtual void onMouseLeave (const RealPoint& pos, wxMouseEvent& ev) {} virtual bool onMouseWheel (const RealPoint& pos, wxMouseEvent& ev) { return false; } - /// Key events + /// Key events. Returns true if event was handled virtual bool onChar(wxKeyEvent& ev) { return false; } /// a context menu is requested, add extra items to the menu m diff --git a/src/gui/value/text.cpp b/src/gui/value/text.cpp index 079d1e2b..5ff3f64a 100644 --- a/src/gui/value/text.cpp +++ b/src/gui/value/text.cpp @@ -416,7 +416,7 @@ bool TextValueEditor::onChar(wxKeyEvent& ev) { } else { moveSelection(TYPE_CURSOR, prevCharBoundary(selection_end), !ev.ShiftDown(), MOVE_LEFT); } - break; + return true; case WXK_RIGHT: // move left (selection?) if (ev.ControlDown()) { @@ -424,11 +424,11 @@ bool TextValueEditor::onChar(wxKeyEvent& ev) { } else { moveSelection(TYPE_CURSOR, nextCharBoundary(selection_end), !ev.ShiftDown(), MOVE_RIGHT); } - break; + return true; case WXK_UP: if ( wordListDropDown(findWordList(selection_end_i)) ) break; moveSelection(TYPE_INDEX, v.moveLine(selection_end_i, -1), !ev.ShiftDown(), MOVE_LEFT_OPT); - break; + return true; case WXK_DOWN: if ( wordListDropDown(findWordList(selection_end_i)) ) break; moveSelection(TYPE_INDEX, v.moveLine(selection_end_i, +1), !ev.ShiftDown(), MOVE_RIGHT_OPT); @@ -440,7 +440,7 @@ bool TextValueEditor::onChar(wxKeyEvent& ev) { } else { moveSelection(TYPE_INDEX, v.lineStart(selection_end_i), !ev.ShiftDown(), MOVE_LEFT_OPT); } - break; + return true; case WXK_END: // move to end of line / all (if control) if (ev.ControlDown()) { @@ -448,7 +448,7 @@ bool TextValueEditor::onChar(wxKeyEvent& ev) { } else { moveSelection(TYPE_INDEX, v.lineEnd(selection_end_i), !ev.ShiftDown(), MOVE_RIGHT_OPT); } - break; + return true; case WXK_BACK: if (selection_start == selection_end) { // if no selection, select previous character @@ -460,7 +460,7 @@ bool TextValueEditor::onChar(wxKeyEvent& ev) { } } replaceSelection(wxEmptyString, _ACTION_("backspace")); - break; + return true; case WXK_DELETE: if (selection_start == selection_end) { // if no selection select next @@ -471,7 +471,7 @@ bool TextValueEditor::onChar(wxKeyEvent& ev) { } } replaceSelection(wxEmptyString, _ACTION_("delete")); - break; + return true; case WXK_RETURN: if (field().multi_line) { if (ev.ShiftDown()) { @@ -481,7 +481,7 @@ bool TextValueEditor::onChar(wxKeyEvent& ev) { replaceSelection(_("\n"), _ACTION_("enter")); } } - break; + return true; default: #ifdef __WXMSW__ if (ev.GetKeyCode() >= _(' ') && ev.GetKeyCode() == (int)ev.GetRawKeyCode()) { @@ -498,11 +498,11 @@ bool TextValueEditor::onChar(wxKeyEvent& ev) { #else replaceSelection(escape(String((Char)ev.GetKeyCode(), 1)), _ACTION_("typing"), true); #endif + return true; } else { return false; } } - return true; } // ----------------------------------------------------------------------------- : Spellchecking