Browse Source

Enable Copy Embedded File Reference context menu on macOS

Using wxID_COPY checks under the hood whether the item
should be enabled or not; we need to use a custom ID
to avoid this behavior.
pcb_db
JamesJCode 12 months ago
parent
commit
6a9e195d19
  1. 29
      common/dialogs/panel_embedded_files.cpp

29
common/dialogs/panel_embedded_files.cpp

@ -84,23 +84,26 @@ void PANEL_EMBEDDED_FILES::resizeGrid()
void PANEL_EMBEDDED_FILES::onGridRightClick( wxGridEvent& event )
{
wxMenu menu;
menu.Append( wxID_COPY, _( "Copy Embedded Reference" ) );
const wxWindowID id = NewControlId();
menu.Append( id, _( "Copy Embedded Reference" ) );
menu.Bind( wxEVT_COMMAND_MENU_SELECTED,
[&]( wxCommandEvent& )
{
int row = event.GetRow();
if( row >= 0 && row < m_files_grid->GetNumberRows() )
menu.Bind(
wxEVT_COMMAND_MENU_SELECTED,
[&]( wxCommandEvent& )
{
wxString cellValue = m_files_grid->GetCellValue( row, 1 );
if( wxTheClipboard->Open() )
int row = event.GetRow();
if( row >= 0 && row < m_files_grid->GetNumberRows() )
{
wxTheClipboard->SetData( new wxTextDataObject( cellValue ) );
wxTheClipboard->Close();
wxString cellValue = m_files_grid->GetCellValue( row, 1 );
if( wxTheClipboard->Open() )
{
wxTheClipboard->SetData( new wxTextDataObject( cellValue ) );
wxTheClipboard->Close();
}
}
}
}, wxID_COPY );
},
id );
PopupMenu( &menu );
}

Loading…
Cancel
Save