]> git.saurik.com Git - wxWidgets.git/commitdiff
Handle inline editing in generic wxDataViewCtrl as Windows 7 does.
authorVáclav Slavík <vslavik@fastmail.fm>
Fri, 7 Oct 2011 17:24:06 +0000 (17:24 +0000)
committerVáclav Slavík <vslavik@fastmail.fm>
Fri, 7 Oct 2011 17:24:06 +0000 (17:24 +0000)
Mimic the behavior of Windows 7's Explorer: edit the item that has focus
if it is selected or the first selected item if focus is out of
selection.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@69323 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

src/generic/datavgen.cpp

index 818889d59ae6e5d71804810d99f896d513df603f..d962bfd8f8ee04235c24c38fa9b6d16f272826ba 100644 (file)
@@ -3583,7 +3583,17 @@ void wxDataViewMainWindow::OnChar( wxKeyEvent &event )
             {
                 if( !m_selection.empty() )
                 {
-                    const wxDataViewItem item = GetItemByRow(m_selection[0]);
+                    // Mimic Windows 7 behavior: edit the item that has focus
+                    // if it is selected and the first selected item if focus
+                    // is out of selection.
+                    int sel;
+                    if ( m_selection.Index(m_currentRow) != wxNOT_FOUND )
+                        sel = m_currentRow;
+                    else
+                        sel = m_selection[0];
+
+
+                    const wxDataViewItem item = GetItemByRow(sel);
 
                     // Edit the current column. If not column is focused
                     // (typically because the user has full row selected), try