From 8c106821456125dc6802dc22afbb339899b4d0bd Mon Sep 17 00:00:00 2001 From: David Bailes Date: Mon, 25 Mar 2019 11:42:30 +0000 Subject: [PATCH] Accessibility: make Grid accessible using Narrator Problem: Using the Narrator screen reader on Windows 10: 1. Narrator does not read the uneditable cells in the tag column of the Metadata editor. 2. In one or more versions of Windows 10 prior to 1809, Narrator's focus was incorrect after editing a cell. Fixes: 1. Fixed by adding wxACC_STATE_SYSTEM_FOCUSED to the state. 2. Corrected GridAx::GetFocus(). --- src/widgets/Grid.cpp | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/src/widgets/Grid.cpp b/src/widgets/Grid.cpp index 43e47f20d..bbe550802 100644 --- a/src/widgets/Grid.cpp +++ b/src/widgets/Grid.cpp @@ -859,7 +859,10 @@ wxAccStatus GridAx::GetState(int childId, long *state) wxACC_STATE_SYSTEM_SELECTED; if (mGrid->IsReadOnly(row, col)) { - flag = wxACC_STATE_SYSTEM_UNAVAILABLE; + // It would be more logical to also include the state + // wxACC_STATE_SYSTEM_FOCUSABLE, but this causes Window-Eyes to + // no longer read the cell as disabled + flag = wxACC_STATE_SYSTEM_UNAVAILABLE | wxACC_STATE_SYSTEM_FOCUSED; } #endif @@ -925,9 +928,17 @@ wxAccStatus GridAx::Select(int childId, wxAccSelectionFlags selectFlags) // If childId is 0 and child is NULL, no object in // this subhierarchy has the focus. // If this object has the focus, child should be 'this'. -wxAccStatus GridAx::GetFocus(int * WXUNUSED(childId), wxAccessible **child) +wxAccStatus GridAx::GetFocus(int * childId, wxAccessible **child) { - *child = this; + if (mGrid == wxWindow::FindFocus()) { + if (mGrid->GetNumberRows() * mGrid->GetNumberCols() == 0) { + *child = this; + } + else { + *childId = mGrid->GetGridCursorRow()*mGrid->GetNumberCols() + + mGrid->GetGridCursorCol() + 1; + } + } return wxACC_OK; }