Use wxWidgets IDs for cut/copy/paste.
This allows them to work in places like search boxes in standard file dialogs. If wxWidgets doesn't find the standard IDs in our menus then it won't enable them.
This commit is contained in:
parent
05785ac6b9
commit
5c9aed62aa
|
@ -466,8 +466,14 @@ void ACTION_MENU::OnMenuEvent( wxMenuEvent& aEvent )
|
|||
}
|
||||
|
||||
// Check if there is a TOOL_ACTION for the given ID
|
||||
if( m_selected >= TOOL_ACTION::GetBaseUIId() )
|
||||
// Note that we also have to check the standard wxWidgets' cut/copy/paste IDs because
|
||||
// we can't use our own IDs there without losing cut/copy/paste in places like search
|
||||
// boxes in standard file dialogs.
|
||||
if( m_selected == wxID_CUT || m_selected == wxID_COPY || m_selected == wxID_PASTE
|
||||
|| m_selected >= TOOL_ACTION::GetBaseUIId() )
|
||||
{
|
||||
evt = findToolAction( m_selected );
|
||||
}
|
||||
|
||||
if( !evt )
|
||||
{
|
||||
|
|
|
@ -151,19 +151,19 @@ TOOL_ACTION ACTIONS::cut( "common.Interactive.cut",
|
|||
AS_GLOBAL,
|
||||
MD_CTRL + 'X', LEGACY_HK_NAME( "Cut" ),
|
||||
_( "Cut" ), _( "Cut selected item(s) to clipboard" ),
|
||||
BITMAPS::cut );
|
||||
BITMAPS::cut, AF_NONE, (void*) wxID_CUT );
|
||||
|
||||
TOOL_ACTION ACTIONS::copy( "common.Interactive.copy",
|
||||
AS_GLOBAL,
|
||||
MD_CTRL + 'C', LEGACY_HK_NAME( "Copy" ),
|
||||
_( "Copy" ), _( "Copy selected item(s) to clipboard" ),
|
||||
BITMAPS::copy );
|
||||
BITMAPS::copy, AF_NONE, (void*) wxID_COPY );
|
||||
|
||||
TOOL_ACTION ACTIONS::paste( "common.Interactive.paste",
|
||||
AS_GLOBAL,
|
||||
MD_CTRL + 'V', LEGACY_HK_NAME( "Paste" ),
|
||||
_( "Paste" ), _( "Paste item(s) from clipboard" ),
|
||||
BITMAPS::paste );
|
||||
BITMAPS::paste, AF_NONE, (void*) wxID_PASTE );
|
||||
|
||||
TOOL_ACTION ACTIONS::selectAll( "common.Interactive.selectAll",
|
||||
AS_GLOBAL,
|
||||
|
|
|
@ -127,7 +127,20 @@ public:
|
|||
*
|
||||
* @return The unique ID number for use in the user interface system.
|
||||
*/
|
||||
int GetUIId() const { return m_id + ACTION_BASE_UI_ID; }
|
||||
int GetUIId() const
|
||||
{
|
||||
// Hack for wxWidgets' use in stuff like search controls in standard file dialogs. If
|
||||
// it doesn't find these specific IDs somewhere in the menus then it won't enable
|
||||
// cut/copy/paste.
|
||||
if( m_param == (void*) wxID_CUT )
|
||||
return wxID_CUT;
|
||||
else if( m_param == (void*) wxID_COPY )
|
||||
return wxID_COPY;
|
||||
else if( m_param == (void*) wxID_PASTE )
|
||||
return wxID_PASTE;
|
||||
|
||||
return m_id + ACTION_BASE_UI_ID;
|
||||
}
|
||||
|
||||
/*
|
||||
* Get the base value used to offset the user interface IDs for the actions.
|
||||
|
|
|
@ -257,14 +257,24 @@ void KICAD_MANAGER_FRAME::setupUIConditions()
|
|||
return m_active_project;
|
||||
};
|
||||
|
||||
#define ENABLE( x ) ACTION_CONDITIONS().Enable( x )
|
||||
|
||||
ACTION_CONDITIONS activeProjectCond;
|
||||
activeProjectCond.Enable( activeProject );
|
||||
|
||||
manager->SetConditions( ACTIONS::saveAs, activeProjectCond );
|
||||
manager->SetConditions( KICAD_MANAGER_ACTIONS::closeProject, activeProjectCond );
|
||||
|
||||
// These are just here for text boxes, search boxes, etc. in places such as the standard
|
||||
// file dialogs.
|
||||
manager->SetConditions( ACTIONS::cut, ENABLE( SELECTION_CONDITIONS::ShowNever ) );
|
||||
manager->SetConditions( ACTIONS::copy, ENABLE( SELECTION_CONDITIONS::ShowNever ) );
|
||||
manager->SetConditions( ACTIONS::paste, ENABLE( SELECTION_CONDITIONS::ShowNever ) );
|
||||
|
||||
// TODO: Switch this to an action
|
||||
RegisterUIUpdateHandler( ID_SAVE_AND_ZIP_FILES, activeProjectCond );
|
||||
|
||||
#undef ENABLE
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -129,6 +129,19 @@ void KICAD_MANAGER_FRAME::ReCreateMenuBar()
|
|||
fileMenu->AppendSeparator();
|
||||
fileMenu->AddQuitOrClose( nullptr, "KiCad" );
|
||||
|
||||
//-- Edit menu -----------------------------------------------------------
|
||||
//
|
||||
|
||||
ACTION_MENU* editMenu = new ACTION_MENU( false, controlTool );
|
||||
|
||||
/*
|
||||
* While we don't presently use these, they need to be here so that cut/copy/paste work
|
||||
* in things like search boxes in file open dialogs.
|
||||
*/
|
||||
editMenu->Add( ACTIONS::cut );
|
||||
editMenu->Add( ACTIONS::copy );
|
||||
editMenu->Add( ACTIONS::paste );
|
||||
|
||||
//-- View menu -----------------------------------------------------------
|
||||
//
|
||||
ACTION_MENU* viewMenu = new ACTION_MENU( false, controlTool );
|
||||
|
@ -198,6 +211,7 @@ void KICAD_MANAGER_FRAME::ReCreateMenuBar()
|
|||
//-- Menubar -------------------------------------------------------------
|
||||
//
|
||||
menuBar->Append( fileMenu, _( "&File" ) );
|
||||
menuBar->Append( editMenu, _( "&Edit" ) );
|
||||
menuBar->Append( viewMenu, _( "&View" ) );
|
||||
menuBar->Append( toolsMenu, _( "&Tools" ) );
|
||||
menuBar->Append( prefsMenu, _( "&Preferences" ) );
|
||||
|
|
Loading…
Reference in New Issue