← Back to team overview

kicad-developers team mailing list archive

[PATCH] Insert a component in schematic, from the Library Browser, by double clicking on it

 

In eeschema, when inserting a component into the schematic using the
Library Browser tool, you have to select it in the components listbox
and then press the "Insert component into schematic" button to close the
window and return to the schematic.

The attached patch enables the selection and insertion of a component in
schematic by double clicking on it in the Library Browser component
listbox. As the double clicking should have effect only if the Library
Browser was launched to load a component in schematic, the patch checks
for NULL the m_Semaphore variable, used two distinguish the mode in
which the Library Browser is running (modal, used when inserting a
component in schematic, or non-modal).

=== modified file 'eeschema/viewlib_frame.cpp'
--- eeschema/viewlib_frame.cpp	2012-09-22 11:19:37 +0000
+++ eeschema/viewlib_frame.cpp	2012-11-22 16:46:49 +0000
@@ -74,6 +74,7 @@
     /* listbox events */
     EVT_LISTBOX( ID_LIBVIEW_LIB_LIST, LIB_VIEW_FRAME::ClickOnLibList )
     EVT_LISTBOX( ID_LIBVIEW_CMP_LIST, LIB_VIEW_FRAME::ClickOnCmpList )
+    EVT_LISTBOX_DCLICK( ID_LIBVIEW_CMP_LIST, LIB_VIEW_FRAME::DClickOnCmpList )
 
     EVT_MENU( ID_SET_RELATIVE_OFFSET, LIB_VIEW_FRAME::OnSetRelativeOffset )
 END_EVENT_TABLE()
@@ -497,6 +498,12 @@
     }
 }
 
+void LIB_VIEW_FRAME::DClickOnCmpList( wxCommandEvent& event )
+{
+    if (m_Semaphore) {
+        ExportToSchematicLibraryPart ( event );
+    }
+}
 
 void LIB_VIEW_FRAME::ExportToSchematicLibraryPart( wxCommandEvent& event )
 {

=== modified file 'eeschema/viewlib_frame.h'
--- eeschema/viewlib_frame.h	2012-09-12 09:53:11 +0000
+++ eeschema/viewlib_frame.h	2012-11-22 16:43:17 +0000
@@ -166,6 +166,7 @@
     void ExportToSchematicLibraryPart( wxCommandEvent& event );
     void ViewOneLibraryContent( CMP_LIBRARY* Lib, int Flag );
     bool OnRightClick( const wxPoint& MousePos, wxMenu* PopMenu );
+    void DClickOnCmpList( wxCommandEvent& event );
 
     DECLARE_EVENT_TABLE()
 };


Follow ups