From 535f3ae0060520afca4f471c73c42c8c26126a2e Mon Sep 17 00:00:00 2001 From: jean-pierre charras Date: Tue, 21 Jun 2016 11:26:59 -0400 Subject: [PATCH] Fix a (minor) issue in Kicad manager: when the schematic editor or the board editor are run from the project tree frame to edit files of the current project, editors are opened on the background. --- common/draw_panel.cpp | 5 ++++- kicad/class_treeproject_item.cpp | 14 ++++++++++++-- kicad/mainframe.cpp | 3 +-- 3 files changed, 17 insertions(+), 5 deletions(-) diff --git a/common/draw_panel.cpp b/common/draw_panel.cpp index 035420e90f..161f003cf9 100644 --- a/common/draw_panel.cpp +++ b/common/draw_panel.cpp @@ -124,7 +124,10 @@ EDA_DRAW_PANEL::EDA_DRAW_PANEL( EDA_DRAW_FRAME* parent, int id, m_panScrollbarLimits = false; m_enableAutoPan = true; m_ignoreMouseEvents = false; - m_ignoreNextLeftButtonRelease = false; + // Be sure a mouse release button event will be ignored when creating the canvas + // if the mouse click was not made inside the canvas (can happen sometimes, when + // launching an editor from a double click made in an other frame) + m_ignoreNextLeftButtonRelease = true; m_mouseCaptureCallback = NULL; m_endMouseCaptureCallback = NULL; diff --git a/kicad/class_treeproject_item.cpp b/kicad/class_treeproject_item.cpp index 8a6e135a8a..56c5709e3d 100644 --- a/kicad/class_treeproject_item.cpp +++ b/kicad/class_treeproject_item.cpp @@ -189,7 +189,12 @@ void TREEPROJECT_ITEM::Activate( TREE_PROJECT_FRAME* prjframe ) if( fullFileName == frame->SchFileName() ) { // the project's schematic is opened using the *.kiface as part of this process. - frame->RunEeschema( fullFileName ); + // We do not call frame->RunEeschema( fullFileName ), + // because after the double click, for some reason, + // the tree project frame is brought to the foreground after Eeschema is called from here. + // Instead, we post an event, equivalent to click on the eeschema tool in command frame + wxCommandEvent evt( wxEVT_COMMAND_TOOL_CLICKED, ID_TO_SCH ); + wxPostEvent( frame, evt ); } else { @@ -203,7 +208,12 @@ void TREEPROJECT_ITEM::Activate( TREE_PROJECT_FRAME* prjframe ) if( fullFileName == frame->PcbFileName() || fullFileName == frame->PcbLegacyFileName() ) { // the project's BOARD is opened using the *.kiface as part of this process. - frame->RunPcbNew( fullFileName ); + // We do not call frame->RunPcbNew( fullFileName ), + // because after the double click, for some reason, + // the tree project frame is brought to the foreground after PcbNew is called from here. + // Instead, we post an event, equivalent to simple click on the pcb editor tool in command frame + wxCommandEvent evt( wxEVT_COMMAND_TOOL_CLICKED, ID_TO_PCB ); + wxPostEvent( frame, evt ); } else { diff --git a/kicad/mainframe.cpp b/kicad/mainframe.cpp index ae7c9117f0..df0122ae15 100644 --- a/kicad/mainframe.cpp +++ b/kicad/mainframe.cpp @@ -30,6 +30,7 @@ #include #include +#include #include #include #include @@ -325,9 +326,7 @@ void KICAD_MANAGER_FRAME::RunEeschema( const wxString& aProjectSchematicFileName void KICAD_MANAGER_FRAME::OnRunEeschema( wxCommandEvent& event ) { wxFileName fn( GetProjectFileName() ); - fn.SetExt( SchematicFileExtension ); - RunEeschema( fn.GetFullPath() ); }