← Back to team overview

kicad-developers team mailing list archive

Re: [PATCH] Hotkey for editing module with module editor (Ctrl-E)

 

Hi all,

Here is a stripped-down legacy-only patch to complement the GAL
shortcut that is now in the product branch.

However, the GAL shortcut doesn't seem to work for me. I can see the 
GAL shortcut in the context menu, but pressing Ctrl-E over a module 
in GAL mode doesn't seem to do anything.

I noticed that the "MD_CTRL + 'E'" is not "MD_CTRL + int( 'E' )" like 
the other shortcuts, but changing this didn't seem to work either.

Cheers,

John

On Fri, 2015-01-23 at 10:43 +0100, Tomasz Wlostowski wrote:
> On 02.12.2014 22:16, John Beard wrote:
> > On Mon, 2014-12-01 at 13:22 -0500, Wayne Stambaugh wrote:
> >> Hi John,
> >>
> >> Sorry it took so long to try out this patch but I've been busy.  I found
> >> a segfault on the first attempt to use Ctrl-E when no previous item has
> >> been selected.  
> > 
> > D'oh, what a clanger!
> > 
> >> Once you fix this issue, I'll commit the patch.
> > 
> > I have fixed the issue, and I have also added the same functionality to
> > the GAL PCB editor. I have also taken the opportunity to break some
> > duplicated code out into a re-usable function:
> > 
> >     void PCB_EDIT_FRAME::ShowModuleEditorForModule( MODULE* aModule )
> John,
> 
> Please don't work on this in GAL mode. I already implemented that
> feature (alongside the P&S changes).
> 
> Cheers,
> Tom


diff --git a/pcbnew/edit.cpp b/pcbnew/edit.cpp
index 27d6955..d24b8e8 100644
--- a/pcbnew/edit.cpp
+++ b/pcbnew/edit.cpp
@@ -848,6 +848,11 @@ void PCB_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event )
         break;
 
     case ID_POPUP_PCB_EDIT_MODULE_WITH_MODEDIT:
+
+        // If we don't have a current item, there's nothing we can do here
+        if( !GetCurItem() )
+            break;
+
         // If the current Item is a pad, text module ...: Get its parent
         if( GetCurItem()->Type() != PCB_MODULE_T )
             SetCurItem( GetCurItem()->GetParent() );
diff --git a/pcbnew/hotkeys.cpp b/pcbnew/hotkeys.cpp
index 662c81b..820ac2d 100644
--- a/pcbnew/hotkeys.cpp
+++ b/pcbnew/hotkeys.cpp
@@ -105,6 +105,7 @@ static EDA_HOTKEY HkSwitchTrackPosture( wxT( "Switch Track Posture" ),  HK_SWITC
 static EDA_HOTKEY HkDragTrackKeepSlope( wxT( "Drag Track Keep Slope" ), HK_DRAG_TRACK_KEEP_SLOPE, 'D' );
 static EDA_HOTKEY HkPlaceItem( wxT( "Place Item" ), HK_PLACE_ITEM, 'P' );
 static EDA_HOTKEY HkEditBoardItem( wxT( "Edit Item" ), HK_EDIT_ITEM, 'E' );
+static EDA_HOTKEY HkEditWithModedit( wxT( "Edit with Footprint Editor" ), HK_EDIT_MODULE_WITH_MODEDIT, 'E' + GR_KB_CTRL );
 static EDA_HOTKEY HkFlipItem( wxT( "Flip Item" ), HK_FLIP_ITEM, 'F' );
 static EDA_HOTKEY HkRotateItem( wxT( "Rotate Item" ), HK_ROTATE_ITEM, 'R' );
 static EDA_HOTKEY HkMoveItem( wxT( "Move Item" ), HK_MOVE_ITEM, 'M' );
@@ -287,6 +288,7 @@ EDA_HOTKEY* board_edit_Hotkey_List[] =
     &HkDragFootprint,
     &HkGetAndMoveFootprint,    &HkLock_Unlock_Footprint,     &HkSavefile, &HkSavefileAs,
     &HkLoadfile,               &HkFindItem,                  &HkEditBoardItem,
+    &HkEditWithModedit,
     &HkSwitch2CopperLayer,     &HkSwitch2InnerLayer1,
     &HkSwitch2InnerLayer2,     &HkSwitch2InnerLayer3,        &HkSwitch2InnerLayer4,
     &HkSwitch2InnerLayer5,     &HkSwitch2InnerLayer6,        &HkSwitch2ComponentLayer,
diff --git a/pcbnew/hotkeys.h b/pcbnew/hotkeys.h
index 661514a..58e998e 100644
--- a/pcbnew/hotkeys.h
+++ b/pcbnew/hotkeys.h
@@ -61,6 +61,7 @@ enum hotkey_id_commnand {
     HK_SWITCH_TRACK_DISPLAY_MODE,
     HK_FIND_ITEM,
     HK_EDIT_ITEM,
+    HK_EDIT_MODULE_WITH_MODEDIT,
     HK_DUPLICATE_ITEM,
     HK_DUPLICATE_ITEM_AND_INCREMENT,
     HK_CREATE_ARRAY,
diff --git a/pcbnew/hotkeys_board_editor.cpp b/pcbnew/hotkeys_board_editor.cpp
index b1a3220..e777100 100644
--- a/pcbnew/hotkeys_board_editor.cpp
+++ b/pcbnew/hotkeys_board_editor.cpp
@@ -508,6 +508,10 @@ bool PCB_EDIT_FRAME::OnHotKey( wxDC* aDC, int aHotkeyCode, const wxPoint& aPosit
         OnHotkeyEditItem( HK_EDIT_ITEM );
         break;
 
+    case HK_EDIT_MODULE_WITH_MODEDIT:      // Edit module with module editor
+        OnHotkeyEditItem( HK_EDIT_MODULE_WITH_MODEDIT );
+        break;
+
     // Footprint edition:
     case HK_LOCK_UNLOCK_FOOTPRINT: // toggle module "MODULE_is_LOCKED" status:
         // get any module, locked or not locked and toggle its locked status
@@ -699,6 +703,8 @@ bool PCB_EDIT_FRAME::OnHotkeyEditItem( int aIdCommand )
     case PCB_MODULE_T:
         if( aIdCommand == HK_EDIT_ITEM )
             evt_type = ID_POPUP_PCB_EDIT_MODULE_PRMS;
+        else if( aIdCommand == HK_EDIT_MODULE_WITH_MODEDIT )
+            evt_type = ID_POPUP_PCB_EDIT_MODULE_WITH_MODEDIT;
 
         break;
 
diff --git a/pcbnew/onrightclick.cpp b/pcbnew/onrightclick.cpp
index 7ef2c47..5580112 100644
--- a/pcbnew/onrightclick.cpp
+++ b/pcbnew/onrightclick.cpp
@@ -864,10 +864,14 @@ void PCB_EDIT_FRAME::createPopUpMenuForFootprints( MODULE* aModule, wxMenu* menu
                              g_Board_Editor_Hokeys_Descr, HK_EDIT_ITEM );
         AddMenuItem( sub_menu_footprint, ID_POPUP_PCB_EDIT_MODULE_PRMS, msg,
                      KiBitmap( edit_module_xpm ) );
+
+        msg = AddHotkeyName( _( "Edit with Footprint Editor" ),
+                             g_Board_Editor_Hokeys_Descr, HK_EDIT_MODULE_WITH_MODEDIT );
         AddMenuItem( sub_menu_footprint, ID_POPUP_PCB_EDIT_MODULE_WITH_MODEDIT,
-                     _( "Edit with Footprint Editor" ),
-                     KiBitmap( module_editor_xpm ) );
+                     msg, KiBitmap( module_editor_xpm ) );
+
         sub_menu_footprint->AppendSeparator();
+
         msg = AddHotkeyName( _( "Delete Footprint" ),
                              g_Board_Editor_Hokeys_Descr, HK_DELETE );
         AddMenuItem( sub_menu_footprint, ID_POPUP_PCB_DELETE_MODULE,

Follow ups

References