1
0
mirror of https://github.com/cookiengineer/audacity synced 2025-06-28 14:18:41 +02:00

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.
This commit is contained in:
David Bailes 2019-07-05 09:25:02 +01:00
parent 4a19a3625b
commit f327fef80b
2 changed files with 20 additions and 31 deletions

View File

@ -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)
{

View File

@ -164,8 +164,6 @@ private:
int mCommandWidth;
wxCoord mKeyWidth;
bool mThereHasBeenALeftDown{};
#if wxUSE_ACCESSIBILITY
KeyViewAx *mAx;
#endif