hotkeys: add defaults command to right-click menu

The new (eeschema, so far) hotkeys editor uses the right-click menu for the
reset command, so the reset-to-default function that was added in 6652
(git:0cd7476) was not accessible from eeschema.
This commit is contained in:
Chris Pavlina 2016-03-30 14:51:47 -04:00
parent 5ff3bbb96e
commit fe53ec8c23
2 changed files with 27 additions and 0 deletions

View File

@ -52,7 +52,9 @@ enum ID_WHKL_MENU_IDS
{
ID_EDIT = 2001,
ID_RESET,
ID_DEFAULT,
ID_RESET_ALL,
ID_DEFAULT_ALL,
};
@ -359,6 +361,15 @@ void WIDGET_HOTKEY_LIST::ResetItem( wxTreeListItem aItem )
}
void WIDGET_HOTKEY_LIST::ResetItemToDefault( wxTreeListItem aItem )
{
WIDGET_HOTKEY_CLIENT_DATA* hkdata = GetHKClientData( aItem );
EDA_HOTKEY* hk = &hkdata->GetHotkey();
hk->ResetKeyCodeToDefault();
UpdateFromClientData();
}
void WIDGET_HOTKEY_LIST::OnActivated( wxTreeListEvent& aEvent )
{
EditItem( aEvent.GetItem() );
@ -374,8 +385,10 @@ void WIDGET_HOTKEY_LIST::OnContextMenu( wxTreeListEvent& aEvent )
menu.Append( ID_EDIT, _( "Edit..." ) );
menu.Append( ID_RESET, _( "Reset" ) );
menu.Append( ID_DEFAULT, _( "Default" ) );
menu.Append( wxID_SEPARATOR );
menu.Append( ID_RESET_ALL, _( "Reset all" ) );
menu.Append( ID_DEFAULT_ALL, _( "Reset all to default" ) );
PopupMenu( &menu );
}
@ -393,10 +406,18 @@ void WIDGET_HOTKEY_LIST::OnMenu( wxCommandEvent& aEvent )
ResetItem( m_context_menu_item );
break;
case ID_DEFAULT:
ResetItemToDefault( m_context_menu_item );
break;
case ID_RESET_ALL:
TransferDataToControl();
break;
case ID_DEFAULT_ALL:
TransferDefaultsToControl();
break;
default:
wxFAIL_MSG( wxT( "Unknown ID in context menu event" ) );
}

View File

@ -97,6 +97,12 @@ protected:
*/
void ResetItem( wxTreeListItem aItem );
/**
* Method ResetItemToDefault
* Reset the item to the default value.
*/
void ResetItemToDefault( wxTreeListItem aItem );
/**
* Method OnActivated
* Handle activation of a row.