Not all SCH_DRAW_PANELs have a selection tool.

Fixes: lp:1829981
* https://bugs.launchpad.net/kicad/+bug/1829981
This commit is contained in:
Jeff Young 2019-05-22 23:57:54 +01:00
parent 0047f88f82
commit 1f2bdf895e
2 changed files with 18 additions and 10 deletions

View File

@ -278,6 +278,7 @@ void SCH_DRAW_PANEL::OnCharHook( wxKeyEvent& event )
void SCH_DRAW_PANEL::OnKeyEvent( wxKeyEvent& event )
{
SCH_BASE_FRAME* frame = (SCH_BASE_FRAME*) m_parent;
int localkey = event.GetKeyCode();
bool keyWasHandled = false;
@ -287,6 +288,8 @@ void SCH_DRAW_PANEL::OnKeyEvent( wxKeyEvent& event )
EE_SELECTION_TOOL* selTool = GetParent()->GetToolManager()->GetTool<EE_SELECTION_TOOL>();
if( selTool )
{
if( EE_CONDITIONS::Idle( selTool->GetSelection() ) )
GetParent()->GetToolManager()->RunAction( EE_ACTIONS::selectionActivate, true );
else
@ -294,6 +297,11 @@ void SCH_DRAW_PANEL::OnKeyEvent( wxKeyEvent& event )
keyWasHandled = true; // The key is captured: the key event will be not skipped
}
else if( frame->IsModal() )
{
frame->DismissModal( wxID_CANCEL );
}
}
/* Normalize keys code to easily handle keys from Ctrl+A to Ctrl+Z
* They have an ascii code from 1 to 27 remapped

View File

@ -228,8 +228,6 @@ public:
*/
bool Destroy() override;
protected:
bool IsModal() { return m_modal; }
void SetModal( bool aIsModal ) { m_modal = aIsModal; }
@ -243,6 +241,8 @@ protected:
void DismissModal( bool aRetVal, const wxString& aResult = wxEmptyString );
protected:
/// event handler, routes to derivative specific virtual KiwayMailIn()
void kiway_express( KIWAY_EXPRESS& aEvent );