diff --git a/src/prefs/KeyConfigPrefs.cpp b/src/prefs/KeyConfigPrefs.cpp index 6b19abc52..d5d209f59 100644 --- a/src/prefs/KeyConfigPrefs.cpp +++ b/src/prefs/KeyConfigPrefs.cpp @@ -285,6 +285,10 @@ void KeyConfigPrefs::PopulateOrExchange(ShuttleGui & S) if (mViewType == ViewByKey) { mFilterLabel->SetLabel(_("&Hotkey:")); } + + // Need to layout so that the KeyView is properly sized before populating. + // Otherwise, the initial selection is not scrolled into view. + Layout(); } void KeyConfigPrefs::RefreshBindings() diff --git a/src/widgets/KeyView.cpp b/src/widgets/KeyView.cpp index 6645b7982..9d0bd3573 100644 --- a/src/widgets/KeyView.cpp +++ b/src/widgets/KeyView.cpp @@ -560,6 +560,8 @@ KeyView::RefreshBindings(const wxArrayString & names, const wxArrayString & labels, const wxArrayString & keys) { + bool firsttime = mNodes.GetCount() == 0; + // Start clean mNodes.Clear(); @@ -750,6 +752,12 @@ KeyView::RefreshBindings(const wxArrayString & names, // Refresh the view lines RefreshLines(); + + // Set the selected node if this was the first time through + if (firsttime) + { + SelectNode(LineToIndex(0)); + } } // @@ -1387,7 +1395,7 @@ KeyView::OnKeyDown(wxKeyEvent & event) int cnt = (int) mLines.GetCount(); bool found = false; - // Search the entire list if not is currently selected + // Search the entire list if none is currently selected if (line == wxNOT_FOUND) { line = cnt; @@ -1742,7 +1750,7 @@ KeyView::GetLineHeight(int line) // // Returns the value to be presented to accessibility // -// Current, the command and key are both provided. +// Currently, the command and key are both provided. // wxString KeyView::GetValue(int line) @@ -1753,18 +1761,20 @@ KeyView::GetValue(int line) wxASSERT(false); return wxEmptyString; } + int index = LineToIndex(line); + KeyNode *node = &mNodes[index]; // Get the label and key values wxString value; if (mViewType == ViewByTree) { - value = GetLabel(LineToIndex(line)); + value = GetLabel(index); } else { - value = GetFullLabel(LineToIndex(line)); + value = GetFullLabel(index); } - wxString key = GetKey(LineToIndex(line)); + wxString key = GetKey(index); // Add the key if it isn't empty if (!key.IsEmpty()) @@ -1779,9 +1789,23 @@ KeyView::GetValue(int line) } } + if (node->isparent) + { + value += wxString::Format(_(" Level %d"), node->depth).c_str(); + } + return value; } +// +// Returns the current view type +// +ViewByType +KeyView::GetViewType() +{ + return mViewType; +} + // ============================================================================ // Accessibility provider for the KeyView class // ============================================================================ @@ -2014,7 +2038,7 @@ KeyViewAx::GetRole(int childId, wxAccRole *role) if (childId == wxACC_SELF) { #if defined(__WXMSW__) - *role = wxROLE_SYSTEM_OUTLINE; + *role = mView->GetViewType() == ViewByTree ? wxROLE_SYSTEM_OUTLINE : wxROLE_SYSTEM_LIST; #endif #if defined(__WXMAC__) @@ -2026,7 +2050,7 @@ KeyViewAx::GetRole(int childId, wxAccRole *role) #if defined(__WXMAC__) *role = wxROLE_SYSTEM_TEXT; #else - *role = wxROLE_SYSTEM_OUTLINEITEM; + *role = mView->GetViewType() == ViewByTree ? wxROLE_SYSTEM_OUTLINEITEM : wxROLE_SYSTEM_LISTITEM; #endif } diff --git a/src/widgets/KeyView.h b/src/widgets/KeyView.h index 0590ad076..35a4f7934 100644 --- a/src/widgets/KeyView.h +++ b/src/widgets/KeyView.h @@ -141,6 +141,7 @@ private: bool IsExpanded(int line); wxCoord GetLineHeight(int line); wxString GetValue(int line); + ViewByType GetViewType(); #endif private: