From: Robert Roebling Date: Tue, 22 Feb 2000 15:29:59 +0000 (+0000) Subject: SetSelection() in wxNotebook now sets the focus, X-Git-Url: https://git.saurik.com/wxWidgets.git/commitdiff_plain/33d0e17c11ec2ad4aa8d2e18bfeb3173cfb2ce61?ds=sidebyside SetSelection() in wxNotebook now sets the focus, 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 --- diff --git a/samples/notebook/test.cpp b/samples/notebook/test.cpp index 39da5d394a..573d302e3b 100644 --- a/samples/notebook/test.cpp +++ b/samples/notebook/test.cpp @@ -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(); diff --git a/samples/notebook/test.h b/samples/notebook/test.h index 9cbcc2d0ff..33b31a06af 100644 --- a/samples/notebook/test.h +++ b/samples/notebook/test.h @@ -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 diff --git a/src/generic/listctrl.cpp b/src/generic/listctrl.cpp index 9eb3fed218..440f6ae775 100644 --- a/src/generic/listctrl.cpp +++ b/src/generic/listctrl.cpp @@ -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: diff --git a/src/gtk/notebook.cpp b/src/gtk/notebook.cpp index 2d4ed460a5..7744b3e1c3 100644 --- a/src/gtk/notebook.cpp +++ b/src/gtk/notebook.cpp @@ -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; } diff --git a/src/gtk1/notebook.cpp b/src/gtk1/notebook.cpp index 2d4ed460a5..7744b3e1c3 100644 --- a/src/gtk1/notebook.cpp +++ b/src/gtk1/notebook.cpp @@ -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; }