Symbol Chooser Dialog: forward chars to panel
Fixes: https://gitlab.com/kicad/code/kicad/-/issues/16350#note_1694513334
This commit is contained in:
parent
5709d57824
commit
5704b3f422
|
@ -102,17 +102,10 @@ DIALOG_SYMBOL_CHOOSER::DIALOG_SYMBOL_CHOOSER( SCH_BASE_FRAME* aParent, const LIB
|
||||||
SetInitialFocus( m_chooserPanel->GetFocusTarget() );
|
SetInitialFocus( m_chooserPanel->GetFocusTarget() );
|
||||||
SetupStandardButtons();
|
SetupStandardButtons();
|
||||||
|
|
||||||
Bind( wxEVT_CHAR_HOOK,
|
|
||||||
[&]( wxKeyEvent& aEvent )
|
|
||||||
{
|
|
||||||
if( aEvent.GetKeyCode() == WXK_ESCAPE )
|
|
||||||
{
|
|
||||||
m_chooserPanel->FinishSetup();
|
|
||||||
}
|
|
||||||
} );
|
|
||||||
|
|
||||||
m_chooserPanel->FinishSetup();
|
m_chooserPanel->FinishSetup();
|
||||||
Layout();
|
Layout();
|
||||||
|
|
||||||
|
Bind( wxEVT_CHAR_HOOK, &PANEL_SYMBOL_CHOOSER::OnChar, m_chooserPanel );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -261,6 +261,7 @@ PANEL_SYMBOL_CHOOSER::PANEL_SYMBOL_CHOOSER( SCH_BASE_FRAME* aFrame, wxWindow* aP
|
||||||
Bind( wxEVT_TIMER, &PANEL_SYMBOL_CHOOSER::onCloseTimer, this, m_dbl_click_timer->GetId() );
|
Bind( wxEVT_TIMER, &PANEL_SYMBOL_CHOOSER::onCloseTimer, this, m_dbl_click_timer->GetId() );
|
||||||
Bind( EVT_LIBITEM_SELECTED, &PANEL_SYMBOL_CHOOSER::onSymbolSelected, this );
|
Bind( EVT_LIBITEM_SELECTED, &PANEL_SYMBOL_CHOOSER::onSymbolSelected, this );
|
||||||
Bind( EVT_LIBITEM_CHOSEN, &PANEL_SYMBOL_CHOOSER::onSymbolChosen, this );
|
Bind( EVT_LIBITEM_CHOSEN, &PANEL_SYMBOL_CHOOSER::onSymbolChosen, this );
|
||||||
|
Bind( wxEVT_CHAR_HOOK, &PANEL_SYMBOL_CHOOSER::OnChar, this );
|
||||||
|
|
||||||
if( m_fp_sel_ctrl )
|
if( m_fp_sel_ctrl )
|
||||||
{
|
{
|
||||||
|
@ -274,37 +275,6 @@ PANEL_SYMBOL_CHOOSER::PANEL_SYMBOL_CHOOSER( SCH_BASE_FRAME* aFrame, wxWindow* aP
|
||||||
wxKeyEventHandler( PANEL_SYMBOL_CHOOSER::OnDetailsCharHook ),
|
wxKeyEventHandler( PANEL_SYMBOL_CHOOSER::OnDetailsCharHook ),
|
||||||
nullptr, this );
|
nullptr, this );
|
||||||
}
|
}
|
||||||
|
|
||||||
Bind( wxEVT_CHAR_HOOK,
|
|
||||||
[&]( wxKeyEvent& aEvent )
|
|
||||||
{
|
|
||||||
if( aEvent.GetKeyCode() == WXK_ESCAPE )
|
|
||||||
{
|
|
||||||
wxObject* eventSource = aEvent.GetEventObject();
|
|
||||||
|
|
||||||
if( wxTextCtrl* textCtrl = dynamic_cast<wxTextCtrl*>( eventSource ) )
|
|
||||||
{
|
|
||||||
// First escape cancels search string value
|
|
||||||
if( textCtrl->GetValue() == m_tree->GetSearchString()
|
|
||||||
&& !m_tree->GetSearchString().IsEmpty() )
|
|
||||||
{
|
|
||||||
m_tree->SetSearchString( wxEmptyString );
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
m_escapeHandler();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
// aEvent.Skip() should be sufficient to allow the normal key events to be
|
|
||||||
// generated (at least according to the wxWidgets documentation). And yet,
|
|
||||||
// here we are.
|
|
||||||
aEvent.DoAllowNextEvent();
|
|
||||||
|
|
||||||
aEvent.Skip();
|
|
||||||
}
|
|
||||||
} );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -313,6 +283,7 @@ PANEL_SYMBOL_CHOOSER::~PANEL_SYMBOL_CHOOSER()
|
||||||
Unbind( wxEVT_TIMER, &PANEL_SYMBOL_CHOOSER::onCloseTimer, this );
|
Unbind( wxEVT_TIMER, &PANEL_SYMBOL_CHOOSER::onCloseTimer, this );
|
||||||
Unbind( EVT_LIBITEM_SELECTED, &PANEL_SYMBOL_CHOOSER::onSymbolSelected, this );
|
Unbind( EVT_LIBITEM_SELECTED, &PANEL_SYMBOL_CHOOSER::onSymbolSelected, this );
|
||||||
Unbind( EVT_LIBITEM_CHOSEN, &PANEL_SYMBOL_CHOOSER::onSymbolChosen, this );
|
Unbind( EVT_LIBITEM_CHOSEN, &PANEL_SYMBOL_CHOOSER::onSymbolChosen, this );
|
||||||
|
Unbind( wxEVT_CHAR_HOOK, &PANEL_SYMBOL_CHOOSER::OnChar, this );
|
||||||
|
|
||||||
// Stop the timer during destruction early to avoid potential race conditions (that do happen)
|
// Stop the timer during destruction early to avoid potential race conditions (that do happen)
|
||||||
m_dbl_click_timer->Stop();
|
m_dbl_click_timer->Stop();
|
||||||
|
@ -351,6 +322,32 @@ PANEL_SYMBOL_CHOOSER::~PANEL_SYMBOL_CHOOSER()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void PANEL_SYMBOL_CHOOSER::OnChar( wxKeyEvent& aEvent )
|
||||||
|
{
|
||||||
|
if( aEvent.GetKeyCode() == WXK_ESCAPE )
|
||||||
|
{
|
||||||
|
wxObject* eventSource = aEvent.GetEventObject();
|
||||||
|
|
||||||
|
if( wxTextCtrl* textCtrl = dynamic_cast<wxTextCtrl*>( eventSource ) )
|
||||||
|
{
|
||||||
|
// First escape cancels search string value
|
||||||
|
if( textCtrl->GetValue() == m_tree->GetSearchString()
|
||||||
|
&& !m_tree->GetSearchString().IsEmpty() )
|
||||||
|
{
|
||||||
|
m_tree->SetSearchString( wxEmptyString );
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
m_escapeHandler();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
aEvent.Skip();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
wxPanel* PANEL_SYMBOL_CHOOSER::constructRightPanel( wxWindow* aParent )
|
wxPanel* PANEL_SYMBOL_CHOOSER::constructRightPanel( wxWindow* aParent )
|
||||||
{
|
{
|
||||||
EDA_DRAW_PANEL_GAL::GAL_TYPE backend;
|
EDA_DRAW_PANEL_GAL::GAL_TYPE backend;
|
||||||
|
|
|
@ -65,6 +65,8 @@ public:
|
||||||
|
|
||||||
~PANEL_SYMBOL_CHOOSER();
|
~PANEL_SYMBOL_CHOOSER();
|
||||||
|
|
||||||
|
void OnChar( wxKeyEvent& aEvent );
|
||||||
|
|
||||||
void FinishSetup();
|
void FinishSetup();
|
||||||
|
|
||||||
void SetPreselect( const LIB_ID& aPreselect );
|
void SetPreselect( const LIB_ID& aPreselect );
|
||||||
|
|
Loading…
Reference in New Issue