cvpcb: Fix some issues
* ESC no longer closed the window since it didn't properly generate the close event * Copy/Cut from a context menu did not work due to a focus-loss issue * Add better error handling for the copy/cut/paste actions to prevent text that isn't an FPID from being inserted
This commit is contained in:
parent
1a3f4fb38b
commit
a1d3f3486e
|
@ -212,8 +212,12 @@ void CVPCB_MAINFRAME::setupTools()
|
||||||
|
|
||||||
CVPCB_CONTROL* tool = m_toolManager->GetTool<CVPCB_CONTROL>();
|
CVPCB_CONTROL* tool = m_toolManager->GetTool<CVPCB_CONTROL>();
|
||||||
|
|
||||||
|
// Even though these menus will open with the right-click, we treat them as a normal
|
||||||
|
// menu instead of a context menu because we don't care about their position and want
|
||||||
|
// to be able to tell the difference between a menu click and a hotkey activation.
|
||||||
|
|
||||||
// Create the context menu for the component list box
|
// Create the context menu for the component list box
|
||||||
m_componentContextMenu = new ACTION_MENU( true );
|
m_componentContextMenu = new ACTION_MENU( false );
|
||||||
m_componentContextMenu->SetTool( tool );
|
m_componentContextMenu->SetTool( tool );
|
||||||
m_componentContextMenu->Add( CVPCB_ACTIONS::showFootprintViewer );
|
m_componentContextMenu->Add( CVPCB_ACTIONS::showFootprintViewer );
|
||||||
m_componentContextMenu->AppendSeparator();
|
m_componentContextMenu->AppendSeparator();
|
||||||
|
@ -224,7 +228,7 @@ void CVPCB_MAINFRAME::setupTools()
|
||||||
m_componentContextMenu->Add( CVPCB_ACTIONS::deleteAssoc );
|
m_componentContextMenu->Add( CVPCB_ACTIONS::deleteAssoc );
|
||||||
|
|
||||||
// Create the context menu for the footprint list box
|
// Create the context menu for the footprint list box
|
||||||
m_footprintContextMenu = new ACTION_MENU( true );
|
m_footprintContextMenu = new ACTION_MENU( false );
|
||||||
m_footprintContextMenu->SetTool( tool );
|
m_footprintContextMenu->SetTool( tool );
|
||||||
m_footprintContextMenu->Add( CVPCB_ACTIONS::showFootprintViewer );
|
m_footprintContextMenu->Add( CVPCB_ACTIONS::showFootprintViewer );
|
||||||
}
|
}
|
||||||
|
@ -248,7 +252,7 @@ void CVPCB_MAINFRAME::setupEventHandlers()
|
||||||
m_saveAndContinue->Bind( wxEVT_COMMAND_BUTTON_CLICKED,
|
m_saveAndContinue->Bind( wxEVT_COMMAND_BUTTON_CLICKED,
|
||||||
[this]( wxCommandEvent& )
|
[this]( wxCommandEvent& )
|
||||||
{
|
{
|
||||||
// saveAssociations must be run immediatley
|
// saveAssociations must be run immediately
|
||||||
this->GetToolManager()->RunAction( CVPCB_ACTIONS::saveAssociations, true );
|
this->GetToolManager()->RunAction( CVPCB_ACTIONS::saveAssociations, true );
|
||||||
} );
|
} );
|
||||||
|
|
||||||
|
@ -256,7 +260,7 @@ void CVPCB_MAINFRAME::setupEventHandlers()
|
||||||
Bind( wxEVT_BUTTON,
|
Bind( wxEVT_BUTTON,
|
||||||
[this]( wxCommandEvent& )
|
[this]( wxCommandEvent& )
|
||||||
{
|
{
|
||||||
// saveAssociations must be run immediatley, before running Close( true )
|
// saveAssociations must be run immediately, before running Close( true )
|
||||||
this->GetToolManager()->RunAction( CVPCB_ACTIONS::saveAssociations, true );
|
this->GetToolManager()->RunAction( CVPCB_ACTIONS::saveAssociations, true );
|
||||||
Close( true );
|
Close( true );
|
||||||
}, wxID_OK );
|
}, wxID_OK );
|
||||||
|
@ -446,6 +450,7 @@ void CVPCB_MAINFRAME::AssociateFootprint( const CVPCB_ASSOCIATION& aAssociation,
|
||||||
wxString msg =
|
wxString msg =
|
||||||
wxString::Format( _( "\"%s\" is not a valid footprint." ), fpid.Format().wx_str() );
|
wxString::Format( _( "\"%s\" is not a valid footprint." ), fpid.Format().wx_str() );
|
||||||
DisplayErrorMessage( this, msg );
|
DisplayErrorMessage( this, msg );
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set the new footprint
|
// Set the new footprint
|
||||||
|
|
|
@ -50,7 +50,15 @@ int CVPCB_ASSOCIATION_TOOL::CopyAssoc( const TOOL_EVENT& aEvent )
|
||||||
{
|
{
|
||||||
COMPONENT* comp;
|
COMPONENT* comp;
|
||||||
LIB_ID fpid;
|
LIB_ID fpid;
|
||||||
switch( m_frame->GetFocusedControl() )
|
|
||||||
|
// Default to using the component control as the source of the copy
|
||||||
|
CVPCB_MAINFRAME::CONTROL_TYPE copyControl = CVPCB_MAINFRAME::CONTROL_COMPONENT;
|
||||||
|
|
||||||
|
// If using the keyboard to copy, find out what control we are in and use that.
|
||||||
|
if( aEvent.HasPosition() )
|
||||||
|
copyControl = m_frame->GetFocusedControl();
|
||||||
|
|
||||||
|
switch( copyControl )
|
||||||
{
|
{
|
||||||
case CVPCB_MAINFRAME::CONTROL_FOOTPRINT:
|
case CVPCB_MAINFRAME::CONTROL_FOOTPRINT:
|
||||||
fpid.Parse( m_frame->GetSelectedFootprint(), LIB_ID::ID_PCB );
|
fpid.Parse( m_frame->GetSelectedFootprint(), LIB_ID::ID_PCB );
|
||||||
|
@ -84,6 +92,8 @@ int CVPCB_ASSOCIATION_TOOL::CopyAssoc( const TOOL_EVENT& aEvent )
|
||||||
wxTheClipboard->Flush();
|
wxTheClipboard->Flush();
|
||||||
wxTheClipboard->Close();
|
wxTheClipboard->Close();
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
wxLogDebug( "Failed to open the clipboard" );
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -91,8 +101,9 @@ int CVPCB_ASSOCIATION_TOOL::CopyAssoc( const TOOL_EVENT& aEvent )
|
||||||
|
|
||||||
int CVPCB_ASSOCIATION_TOOL::CutAssoc( const TOOL_EVENT& aEvent )
|
int CVPCB_ASSOCIATION_TOOL::CutAssoc( const TOOL_EVENT& aEvent )
|
||||||
{
|
{
|
||||||
// Only cut when in the component frame
|
// If using the keyboard, only cut in the component frame
|
||||||
if( m_frame->GetFocusedControl() != CVPCB_MAINFRAME::CONTROL_COMPONENT )
|
if( aEvent.HasPosition()
|
||||||
|
&& ( m_frame->GetFocusedControl() != CVPCB_MAINFRAME::CONTROL_COMPONENT ) )
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
// Get the selection, but only use the first one
|
// Get the selection, but only use the first one
|
||||||
|
@ -123,6 +134,11 @@ int CVPCB_ASSOCIATION_TOOL::CutAssoc( const TOOL_EVENT& aEvent )
|
||||||
wxTheClipboard->Flush();
|
wxTheClipboard->Flush();
|
||||||
wxTheClipboard->Close();
|
wxTheClipboard->Close();
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
wxLogDebug( "Failed to open the clipboard" );
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
// Remove the association
|
// Remove the association
|
||||||
m_frame->AssociateFootprint( CVPCB_ASSOCIATION( idx.front(), "" ) );
|
m_frame->AssociateFootprint( CVPCB_ASSOCIATION( idx.front(), "" ) );
|
||||||
|
@ -148,6 +164,11 @@ int CVPCB_ASSOCIATION_TOOL::PasteAssoc( const TOOL_EVENT& aEvent )
|
||||||
wxTheClipboard->GetData( data );
|
wxTheClipboard->GetData( data );
|
||||||
wxTheClipboard->Close();
|
wxTheClipboard->Close();
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
wxLogDebug( "Failed to open the clipboard" );
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
if( fpid.Parse( data.GetText(), LIB_ID::ID_PCB ) >= 0 )
|
if( fpid.Parse( data.GetText(), LIB_ID::ID_PCB ) >= 0 )
|
||||||
return 0;
|
return 0;
|
||||||
|
|
|
@ -60,8 +60,7 @@ int CVPCB_CONTROL::Main( const TOOL_EVENT& aEvent )
|
||||||
// The escape key maps to the cancel event, which is used to close the window
|
// The escape key maps to the cancel event, which is used to close the window
|
||||||
if( evt->IsCancel() )
|
if( evt->IsCancel() )
|
||||||
{
|
{
|
||||||
wxCloseEvent dummy;
|
m_frame->Close( false );
|
||||||
m_frame->OnCloseWindow( dummy );
|
|
||||||
handled = true;
|
handled = true;
|
||||||
}
|
}
|
||||||
else if( evt->IsKeyPressed() )
|
else if( evt->IsKeyPressed() )
|
||||||
|
|
Loading…
Reference in New Issue