mirror of
https://gitlab.com/kicad/code/kicad.git
synced 2025-09-14 02:03:12 +02:00
Pass hotkeys from search pane to frame
If the search pane doesn't handle the key, push it through the frame hotkey handling system Fixes https://gitlab.com/kicad/code/kicad/-/issues/12474
This commit is contained in:
parent
f14ba983d6
commit
322c08d5f0
@ -21,6 +21,8 @@
|
||||
|
||||
|
||||
#include <tool/action_menu.h>
|
||||
#include <tool/tool_dispatcher.h>
|
||||
#include <tool/tool_manager.h>
|
||||
#include <settings/app_settings.h>
|
||||
#include <eda_draw_frame.h>
|
||||
#include <bitmaps.h>
|
||||
@ -131,6 +133,7 @@ SEARCH_PANE::SEARCH_PANE( EDA_DRAW_FRAME* aFrame ) :
|
||||
} );
|
||||
|
||||
m_frame->Bind( wxEVT_AUI_PANE_CLOSE, &SEARCH_PANE::OnClosed, this );
|
||||
Bind( wxEVT_CHAR_HOOK, &SEARCH_PANE::OnCharHook, this );
|
||||
}
|
||||
|
||||
|
||||
@ -138,6 +141,7 @@ SEARCH_PANE::~SEARCH_PANE()
|
||||
{
|
||||
m_frame->Unbind( wxEVT_AUI_PANE_CLOSE, &SEARCH_PANE::OnClosed, this );
|
||||
m_frame->Unbind( EDA_LANG_CHANGED, &SEARCH_PANE::OnLanguageChange, this );
|
||||
Unbind( wxEVT_CHAR_HOOK, &SEARCH_PANE::OnCharHook, this );
|
||||
|
||||
delete m_menu;
|
||||
}
|
||||
@ -224,3 +228,25 @@ SEARCH_PANE_TAB* SEARCH_PANE::GetCurrentTab() const
|
||||
{
|
||||
return dynamic_cast<SEARCH_PANE_TAB*>( m_notebook->GetCurrentPage() );
|
||||
}
|
||||
|
||||
|
||||
void SEARCH_PANE::OnCharHook( wxKeyEvent& aEvent )
|
||||
{
|
||||
// Check if the event is from a child window of the search pane
|
||||
wxWindow* eventObject = dynamic_cast<wxWindow*>( aEvent.GetEventObject() );
|
||||
|
||||
if( !eventObject || !IsDescendant( eventObject ) )
|
||||
{
|
||||
aEvent.Skip();
|
||||
return;
|
||||
}
|
||||
|
||||
// Try to let the tool framework handle the event
|
||||
if( m_frame->GetToolDispatcher() )
|
||||
{
|
||||
m_frame->GetToolDispatcher()->DispatchWxEvent( aEvent );
|
||||
return;
|
||||
}
|
||||
|
||||
aEvent.Skip();
|
||||
}
|
||||
|
@ -151,6 +151,8 @@ void SEARCH_PANE_LISTVIEW::OnColClicked( wxListEvent& aEvent )
|
||||
|
||||
void SEARCH_PANE_LISTVIEW::OnChar( wxKeyEvent& aEvent )
|
||||
{
|
||||
bool handled = false;
|
||||
|
||||
switch( aEvent.GetKeyCode() )
|
||||
{
|
||||
case WXK_CONTROL_A:
|
||||
@ -159,6 +161,7 @@ void SEARCH_PANE_LISTVIEW::OnChar( wxKeyEvent& aEvent )
|
||||
for( int row = 0; row < GetItemCount(); row++ )
|
||||
SetItemState( row, wxLIST_STATE_SELECTED, wxLIST_STATE_SELECTED );
|
||||
|
||||
handled = true;
|
||||
break;
|
||||
}
|
||||
|
||||
@ -192,6 +195,7 @@ void SEARCH_PANE_LISTVIEW::OnChar( wxKeyEvent& aEvent )
|
||||
wxTheClipboard->Close();
|
||||
}
|
||||
|
||||
handled = true;
|
||||
break;
|
||||
}
|
||||
|
||||
@ -217,6 +221,8 @@ void SEARCH_PANE_LISTVIEW::OnChar( wxKeyEvent& aEvent )
|
||||
Focus( focused );
|
||||
Select( focused );
|
||||
}
|
||||
|
||||
handled = true;
|
||||
break;
|
||||
}
|
||||
case WXK_UP:
|
||||
@ -243,9 +249,13 @@ void SEARCH_PANE_LISTVIEW::OnChar( wxKeyEvent& aEvent )
|
||||
Select( focused );
|
||||
}
|
||||
|
||||
handled = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if( !handled )
|
||||
aEvent.Skip();
|
||||
}
|
||||
|
||||
|
||||
|
@ -76,6 +76,8 @@ public:
|
||||
void FocusSearch();
|
||||
void ClearAllResults();
|
||||
|
||||
void OnCharHook( wxKeyEvent& aEvent );
|
||||
|
||||
protected:
|
||||
void OnLanguageChange( wxCommandEvent& aEvent );
|
||||
SEARCH_PANE_TAB* GetCurrentTab() const;
|
||||
|
Loading…
x
Reference in New Issue
Block a user