From f327fef80bbcbfb72cd482d2eb06fd3034ee7603 Mon Sep 17 00:00:00 2001 From: David Bailes Date: Fri, 5 Jul 2019 09:25:02 +0100 Subject: [PATCH] Bug 2146: Keyboard preferences: mouse can select wrong item My previous fix for this bug, commit 4b437b8, did not work on Mac. This bug was introduced by my commit b62ed73. This commit was to ensure that when the keyview was the focus, there was always one item selected. This ensures that the focus is indicated visually, and that the Narrator screen reader reads the keyview. The failed fix, selected an item if necessary when the keyview became the focus. The current fix reverts b62ed73 and 4b437b8, and ensures that an item is selected each time the items are updated. --- src/widgets/KeyView.cpp | 49 +++++++++++++++++------------------------ src/widgets/KeyView.h | 2 -- 2 files changed, 20 insertions(+), 31 deletions(-) diff --git a/src/widgets/KeyView.cpp b/src/widgets/KeyView.cpp index 4d2ddd253..6a3b435c8 100644 --- a/src/widgets/KeyView.cpp +++ b/src/widgets/KeyView.cpp @@ -455,6 +455,13 @@ KeyView::SetView(ViewByType type) SelectNode(index); } + // ensure that a node is selected so that when the keyview is the focus, + // this is indicated visually, and the Narrator screen reader reads it. + if ((GetSelection() == wxNOT_FOUND)) + { + SelectNode(LineToIndex(0)); + } + return; } @@ -480,6 +487,13 @@ KeyView::SetFilter(const wxString & filter) { SelectNode(index); } + + // ensure that a node is selected so that when the keyview is the focus, + // this is indicated visually, and the Narrator screen reader reads it. + if ((GetSelection() == wxNOT_FOUND)) + { + SelectNode(LineToIndex(0)); + } } // @@ -1331,37 +1345,18 @@ KeyView::OnSetFocus(wxFocusEvent & event) // Allow further processing event.Skip(); + // Refresh the selected line to pull in any changes while + // focus was away...like when setting a NEW key value. This + // will also refresh the visual (highlighted) state. if (GetSelection() != wxNOT_FOUND) { - // Refresh the selected line to pull in any changes while - // focus was away...like when setting a NEW key value. This - // will also refresh the visual (highlighted) state. RefreshRow(GetSelection()); -#if wxUSE_ACCESSIBILITY - // Tell accessibility of the change - mAx->SetCurrentLine(GetSelection()); -#endif } - else - { - if (mLines.size() > 0) - { - // If mThereHasBeenALeftDown is true, then there is mouse - // selection in progress, so don't select anything here - // as this interferes with the mouse selection. (Bug 2146) - if (!mThereHasBeenALeftDown) { - // if no selection, select first line - SelectNode(LineToIndex(0)); - } - } - else - { + #if wxUSE_ACCESSIBILITY - // Tell accessibility, since there may have been a change - mAx->SetCurrentLine(wxNOT_FOUND); + // Tell accessibility of the change + mAx->SetCurrentLine(GetSelection()); #endif - } - } } // @@ -1378,8 +1373,6 @@ KeyView::OnKillFocus(wxFocusEvent & event) { RefreshRow(GetSelection()); } - - mThereHasBeenALeftDown = false; } // @@ -1625,8 +1618,6 @@ KeyView::OnKeyDown(wxKeyEvent & event) void KeyView::OnLeftDown(wxMouseEvent & event) { - mThereHasBeenALeftDown = true; - // Only check if for tree view if (mViewType != ViewByTree) { diff --git a/src/widgets/KeyView.h b/src/widgets/KeyView.h index 4f0836891..939e8bcaa 100644 --- a/src/widgets/KeyView.h +++ b/src/widgets/KeyView.h @@ -164,8 +164,6 @@ private: int mCommandWidth; wxCoord mKeyWidth; - bool mThereHasBeenALeftDown{}; - #if wxUSE_ACCESSIBILITY KeyViewAx *mAx; #endif