From d00810c0fb8ce919505414db2382410030a220f0 Mon Sep 17 00:00:00 2001 From: Konstantin Baranovskiy Date: Mon, 6 Dec 2021 19:08:23 +0000 Subject: [PATCH] Pcbnew: make search field focused by default in Find dialog --- pcbnew/dialogs/dialog_find.cpp | 10 ++++++++++ pcbnew/dialogs/dialog_find.h | 8 ++++++++ qa/qa_utils/mocks.cpp | 4 ++++ 3 files changed, 22 insertions(+) diff --git a/pcbnew/dialogs/dialog_find.cpp b/pcbnew/dialogs/dialog_find.cpp index c7a99f0b7e..4285dd8e1c 100644 --- a/pcbnew/dialogs/dialog_find.cpp +++ b/pcbnew/dialogs/dialog_find.cpp @@ -383,6 +383,16 @@ void DIALOG_FIND::OnCloseButtonClick( wxCommandEvent& aEvent ) aEvent.Skip(); } +bool DIALOG_FIND::Show( bool show ) +{ + bool ret = DIALOG_FIND_BASE::Show( show ); + + if( show ) + m_searchCombo->SetFocus(); + + return ret; +} + void DIALOG_FIND::OnClose( wxCloseEvent& aEvent ) { diff --git a/pcbnew/dialogs/dialog_find.h b/pcbnew/dialogs/dialog_find.h index f5ca7f4625..925647d6a9 100644 --- a/pcbnew/dialogs/dialog_find.h +++ b/pcbnew/dialogs/dialog_find.h @@ -68,6 +68,14 @@ public: */ void FindNext() { search( true ); } + /** + * The Show method is overridden to make the search combobox + * focused by default. + * wxShowEvent is not suitable here because it supports MSW + * and GTK only. + */ + bool Show( bool show = true ) override; + protected: void OnClose( wxCloseEvent& event ) override; void OnCloseButtonClick( wxCommandEvent& aEvent ) override; diff --git a/qa/qa_utils/mocks.cpp b/qa/qa_utils/mocks.cpp index da786d3148..136ae7df31 100644 --- a/qa/qa_utils/mocks.cpp +++ b/qa/qa_utils/mocks.cpp @@ -168,6 +168,10 @@ void DIALOG_FIND::OnCloseButtonClick( wxCommandEvent& aEvent ) { } +bool DIALOG_FIND::Show( bool show ) +{ +} + void DIALOG_FIND::OnClose( wxCloseEvent& aEvent ) { }