]> git.saurik.com Git - wxWidgets.git/commitdiff
SetSelection() in wxNotebook now sets the focus,
authorRobert Roebling <robert@roebling.de>
Tue, 22 Feb 2000 15:29:59 +0000 (15:29 +0000)
committerRobert Roebling <robert@roebling.de>
Tue, 22 Feb 2000 15:29:59 +0000 (15:29 +0000)
  SPACE in wxListCtrl now sends Activate in multiple sel mode

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

samples/notebook/test.cpp
samples/notebook/test.h
src/generic/listctrl.cpp
src/gtk/notebook.cpp
src/gtk1/notebook.cpp

index 39da5d394acd4e6b9bc4472588e09678690cd33f..573d302e3b7cfde86c73c6a9d233f1ee1c3401e9 100644 (file)
@@ -62,9 +62,17 @@ void MyApp::InitTabView(wxNotebook* notebook, wxPanel* window)
   m_okButton = new wxButton(window, wxID_OK, "Close", wxPoint(-1, -1), wxSize(80, 25));
   m_cancelButton = new wxButton(window, ID_DELETE_PAGE, "Delete page", wxPoint(-1, -1), wxSize(80, 25));
   m_addPageButton = new wxButton(window, ID_ADD_PAGE, "Add page", wxPoint(-1, -1), wxSize(80, 25));
+  m_nextPageButton = new wxButton(window, ID_NEXT_PAGE, "Next page", wxPoint(-1, -1), wxSize(80, 25));
   m_okButton->SetDefault();
 
   wxLayoutConstraints* c = new wxLayoutConstraints;
+  c->right.SameAs(m_addPageButton, wxLeft, 4);
+  c->bottom.SameAs(window, wxBottom, 4);
+  c->height.AsIs();
+  c->width.AsIs();
+  m_nextPageButton->SetConstraints(c);
+
+  c = new wxLayoutConstraints;
   c->right.SameAs(window, wxRight, 4);
   c->bottom.SameAs(window, wxBottom, 4);
   c->height.AsIs();
@@ -189,6 +197,7 @@ BEGIN_EVENT_TABLE(MyFrame, wxFrame)
     EVT_BUTTON(wxID_OK, MyFrame::OnOK)
     EVT_BUTTON(ID_DELETE_PAGE, MyFrame::OnDeletePage)
     EVT_BUTTON(ID_ADD_PAGE, MyFrame::OnAddPage)
+    EVT_BUTTON(ID_NEXT_PAGE, MyFrame::OnNextPage)
     EVT_IDLE(MyFrame::OnIdle)
 END_EVENT_TABLE()
 
@@ -214,6 +223,11 @@ void MyFrame::OnDeletePage(wxCommandEvent& WXUNUSED(event))
     m_notebook->DeletePage( m_notebook->GetPageCount()-1 );
 }
 
+void MyFrame::OnNextPage(wxCommandEvent& WXUNUSED(event))
+{
+    m_notebook->AdvanceSelection();
+}
+
 void MyFrame::OnOK(wxCommandEvent& WXUNUSED(event) )
 {
     Destroy();
index 9cbcc2d0ff93a4b2fb8fc6af07dc8e8b3cd34d91..33b31a06af06ed81d786486886a861b4c1d1cc32 100644 (file)
@@ -21,6 +21,7 @@ public:
     wxButton*   m_okButton;
     wxButton*   m_cancelButton;
     wxButton*   m_addPageButton;
+    wxButton*   m_nextPageButton;
 };
 
 DECLARE_APP(MyApp)
@@ -54,6 +55,7 @@ public:
     void OnOK(wxCommandEvent& event);
     void OnCloseWindow(wxCloseEvent& event);
     void OnAddPage(wxCommandEvent& event);
+    void OnNextPage(wxCommandEvent& event);
     void OnDeletePage(wxCommandEvent& event);
     void OnIdle(wxIdleEvent& event);
 
@@ -88,4 +90,5 @@ protected:
 #define ID_NOTEBOOK         1000
 #define ID_ADD_PAGE         1200
 #define ID_DELETE_PAGE      1201
+#define ID_NEXT_PAGE        1202
 
index 9eb3fed2185545a28ad8738c6438eaa0ac3124ce..440f6ae775af483822f2afc8830afa15d198423f 100644 (file)
@@ -2077,8 +2077,19 @@ void wxListMainWindow::OnChar( wxKeyEvent &event )
         }
         case WXK_SPACE:
         {
-            m_current->ReverseHilight();
-            RefreshLine( m_current );
+            if (m_mode & wxLC_SINGLE_SEL)
+            {
+                wxListEvent le( wxEVT_COMMAND_LIST_ITEM_ACTIVATED, GetParent()->GetId() );
+                le.SetEventObject( GetParent() );
+                le.m_itemIndex = GetIndexOfLine( m_current );
+                m_current->GetItem( 0, le.m_item );
+                GetParent()->GetEventHandler()->ProcessEvent( le );
+            }
+            else
+            {
+                m_current->ReverseHilight();
+                RefreshLine( m_current );
+            }
             break;
         }
         case WXK_INSERT:
index 2d4ed460a5dbbd6bb526cdf38e0d820e90681aa8..7744b3e1c367739a096fb92b304cb8b6fd94bf25 100644 (file)
@@ -357,6 +357,10 @@ int wxNotebook::SetSelection( int page )
     int selOld = GetSelection();
 
     gtk_notebook_set_page( GTK_NOTEBOOK(m_widget), page );
+    
+    wxGtkNotebookPage* g_page = GetNotebookPage( page );
+    if (g_page->m_client) 
+        g_page->m_client->SetFocus();
 
     return selOld;
 }
index 2d4ed460a5dbbd6bb526cdf38e0d820e90681aa8..7744b3e1c367739a096fb92b304cb8b6fd94bf25 100644 (file)
@@ -357,6 +357,10 @@ int wxNotebook::SetSelection( int page )
     int selOld = GetSelection();
 
     gtk_notebook_set_page( GTK_NOTEBOOK(m_widget), page );
+    
+    wxGtkNotebookPage* g_page = GetNotebookPage( page );
+    if (g_page->m_client) 
+        g_page->m_client->SetFocus();
 
     return selOld;
 }