MCPcopy Create free account
hub / github.com/audacity/audacity / OnCopy

Function OnCopy

src/menus/EditMenus.cpp:373–417  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

371
372
373void OnCopy(const CommandContext &context)
374{
375 ClearClipboard();
376
377 auto &project = context.project;
378 auto &tracks = TrackList::Get( project );
379 auto &trackPanel = TrackPanel::Get( project );
380 auto &selectedRegion = ViewInfo::Get( project ).selectedRegion;
381
382 for (auto lt : tracks.Selected<LabelTrack>()) {
383 auto &view = LabelTrackView::Get( *lt );
384 if (view.CopySelectedText( context.project )) {
385 //trackPanel.Refresh(false);
386 return;
387 }
388 }
389 //Presumably, there might be not more than one track
390 //that expects text input
391 for (auto wt : tracks.Any<WaveTrack>()) {
392 auto& view = WaveChannelView::GetFirst(*wt);
393 if (view.CopySelectedText(context.project)) {
394 return;
395 }
396 }
397
398 auto &clipboard = Clipboard::Get();
399 clipboard.Clear();
400
401 auto pNewClipboard = TrackList::Create( nullptr );
402 auto &newClipboard = *pNewClipboard;
403
404 for (auto n : tracks.Selected()) {
405 if (n->SupportsBasicEditing()) {
406 auto dest = n->Copy(selectedRegion.t0(), selectedRegion.t1());
407 newClipboard.Add(dest);
408 }
409 }
410
411 // Survived possibility of exceptions. Commit changes to the clipboard now.
412 clipboard.Assign( std::move( newClipboard ),
413 selectedRegion.t0(), selectedRegion.t1(), project.shared_from_this() );
414
415 //Make sure the menus/toolbar states get updated
416 trackPanel.Refresh(false);
417}
418
419std::pair<double, double> FindSelection(const CommandContext &context)
420{

Callers

nothing calls this directly

Calls 11

ClearClipboardFunction · 0.85
GetFunction · 0.85
CreateFunction · 0.85
moveFunction · 0.85
CopySelectedTextMethod · 0.45
ClearMethod · 0.45
SupportsBasicEditingMethod · 0.45
CopyMethod · 0.45
AddMethod · 0.45
AssignMethod · 0.45
RefreshMethod · 0.45

Tested by

no test coverage detected