From 6fad9cf2d93f4f4ef79ad829149a4c07cd53b981 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Fri, 9 Jan 2015 03:30:02 +0000 Subject: [PATCH] Make generic wxDataViewCtrl initially usable from keyboard. This control doesn't react to the keyboard at all if it doesn't have a current row and as it doesn't have it initially, it means that there is no way to do anything with the control without clicking it with the mouse first. Fix this by giving it a current row, if possible, whenever it gains focus. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@78358 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- src/generic/datavgen.cpp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/generic/datavgen.cpp b/src/generic/datavgen.cpp index 40d635034e..d4e0d100a9 100644 --- a/src/generic/datavgen.cpp +++ b/src/generic/datavgen.cpp @@ -4464,6 +4464,13 @@ void wxDataViewMainWindow::OnSetFocus( wxFocusEvent &event ) { m_hasFocus = true; + // Make the control usable from keyboard once it gets focus by ensuring + // that it has a current row, if at all possible. + if ( !HasCurrentRow() && !IsEmpty() ) + { + ChangeCurrentRow(0); + } + if (HasCurrentRow()) Refresh();