Call ev.Skip() for unhandled char events in card editor. Fixes #65 (and maybe also #53)

This commit is contained in:
Twan van Laarhoven
2020-06-01 13:47:44 +02:00
parent 41de22b182
commit 7952a889c9
3 changed files with 15 additions and 11 deletions
+5 -1
View File
@@ -453,7 +453,11 @@ void DataEditor::onChar(wxKeyEvent& ev) {
GetParent()->HandleWindowEvent(evt); GetParent()->HandleWindowEvent(evt);
} }
} else if (current_editor) { } else if (current_editor) {
current_editor->onChar(ev); if (!current_editor->onChar(ev)) {
ev.Skip();
}
} else {
ev.Skip();
} }
} }
+1 -1
View File
@@ -50,7 +50,7 @@ public:
virtual void onMouseLeave (const RealPoint& pos, wxMouseEvent& ev) {} virtual void onMouseLeave (const RealPoint& pos, wxMouseEvent& ev) {}
virtual bool onMouseWheel (const RealPoint& pos, wxMouseEvent& ev) { return false; } 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; } virtual bool onChar(wxKeyEvent& ev) { return false; }
/// a context menu is requested, add extra items to the menu m /// a context menu is requested, add extra items to the menu m
+9 -9
View File
@@ -416,7 +416,7 @@ bool TextValueEditor::onChar(wxKeyEvent& ev) {
} else { } else {
moveSelection(TYPE_CURSOR, prevCharBoundary(selection_end), !ev.ShiftDown(), MOVE_LEFT); moveSelection(TYPE_CURSOR, prevCharBoundary(selection_end), !ev.ShiftDown(), MOVE_LEFT);
} }
break; return true;
case WXK_RIGHT: case WXK_RIGHT:
// move left (selection?) // move left (selection?)
if (ev.ControlDown()) { if (ev.ControlDown()) {
@@ -424,11 +424,11 @@ bool TextValueEditor::onChar(wxKeyEvent& ev) {
} else { } else {
moveSelection(TYPE_CURSOR, nextCharBoundary(selection_end), !ev.ShiftDown(), MOVE_RIGHT); moveSelection(TYPE_CURSOR, nextCharBoundary(selection_end), !ev.ShiftDown(), MOVE_RIGHT);
} }
break; return true;
case WXK_UP: case WXK_UP:
if ( wordListDropDown(findWordList(selection_end_i)) ) break; if ( wordListDropDown(findWordList(selection_end_i)) ) break;
moveSelection(TYPE_INDEX, v.moveLine(selection_end_i, -1), !ev.ShiftDown(), MOVE_LEFT_OPT); moveSelection(TYPE_INDEX, v.moveLine(selection_end_i, -1), !ev.ShiftDown(), MOVE_LEFT_OPT);
break; return true;
case WXK_DOWN: case WXK_DOWN:
if ( wordListDropDown(findWordList(selection_end_i)) ) break; if ( wordListDropDown(findWordList(selection_end_i)) ) break;
moveSelection(TYPE_INDEX, v.moveLine(selection_end_i, +1), !ev.ShiftDown(), MOVE_RIGHT_OPT); moveSelection(TYPE_INDEX, v.moveLine(selection_end_i, +1), !ev.ShiftDown(), MOVE_RIGHT_OPT);
@@ -440,7 +440,7 @@ bool TextValueEditor::onChar(wxKeyEvent& ev) {
} else { } else {
moveSelection(TYPE_INDEX, v.lineStart(selection_end_i), !ev.ShiftDown(), MOVE_LEFT_OPT); moveSelection(TYPE_INDEX, v.lineStart(selection_end_i), !ev.ShiftDown(), MOVE_LEFT_OPT);
} }
break; return true;
case WXK_END: case WXK_END:
// move to end of line / all (if control) // move to end of line / all (if control)
if (ev.ControlDown()) { if (ev.ControlDown()) {
@@ -448,7 +448,7 @@ bool TextValueEditor::onChar(wxKeyEvent& ev) {
} else { } else {
moveSelection(TYPE_INDEX, v.lineEnd(selection_end_i), !ev.ShiftDown(), MOVE_RIGHT_OPT); moveSelection(TYPE_INDEX, v.lineEnd(selection_end_i), !ev.ShiftDown(), MOVE_RIGHT_OPT);
} }
break; return true;
case WXK_BACK: case WXK_BACK:
if (selection_start == selection_end) { if (selection_start == selection_end) {
// if no selection, select previous character // if no selection, select previous character
@@ -460,7 +460,7 @@ bool TextValueEditor::onChar(wxKeyEvent& ev) {
} }
} }
replaceSelection(wxEmptyString, _ACTION_("backspace")); replaceSelection(wxEmptyString, _ACTION_("backspace"));
break; return true;
case WXK_DELETE: case WXK_DELETE:
if (selection_start == selection_end) { if (selection_start == selection_end) {
// if no selection select next // if no selection select next
@@ -471,7 +471,7 @@ bool TextValueEditor::onChar(wxKeyEvent& ev) {
} }
} }
replaceSelection(wxEmptyString, _ACTION_("delete")); replaceSelection(wxEmptyString, _ACTION_("delete"));
break; return true;
case WXK_RETURN: case WXK_RETURN:
if (field().multi_line) { if (field().multi_line) {
if (ev.ShiftDown()) { if (ev.ShiftDown()) {
@@ -481,7 +481,7 @@ bool TextValueEditor::onChar(wxKeyEvent& ev) {
replaceSelection(_("\n"), _ACTION_("enter")); replaceSelection(_("\n"), _ACTION_("enter"));
} }
} }
break; return true;
default: default:
#ifdef __WXMSW__ #ifdef __WXMSW__
if (ev.GetKeyCode() >= _(' ') && ev.GetKeyCode() == (int)ev.GetRawKeyCode()) { if (ev.GetKeyCode() >= _(' ') && ev.GetKeyCode() == (int)ev.GetRawKeyCode()) {
@@ -498,11 +498,11 @@ bool TextValueEditor::onChar(wxKeyEvent& ev) {
#else #else
replaceSelection(escape(String((Char)ev.GetKeyCode(), 1)), _ACTION_("typing"), true); replaceSelection(escape(String((Char)ev.GetKeyCode(), 1)), _ACTION_("typing"), true);
#endif #endif
return true;
} else { } else {
return false; return false;
} }
} }
return true;
} }
// ----------------------------------------------------------------------------- : Spellchecking // ----------------------------------------------------------------------------- : Spellchecking