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

Method CopySelectedText

src/tracks/ui/TextEditHelper.cpp:642–666  ·  view source on GitHub ↗

Copy the selected text in the text box @return true if text is selected in text box, false otherwise

Source from the content-addressed store, hash-verified

640/// Copy the selected text in the text box
641/// @return true if text is selected in text box, false otherwise
642bool TextEditHelper::CopySelectedText(AudacityProject& project)
643{
644 if (mCurrentCursorPos == mInitialCursorPos)
645 return false;
646
647 int init = mInitialCursorPos;
648 int cur = mCurrentCursorPos;
649 if (init > cur)
650 std::swap(init, cur);
651
652 if (init == cur)
653 return false;
654
655 // data for copying
656 wxString data = mText.Mid(init, cur - init);
657
658 // copy the data on clipboard
659 if (wxTheClipboard->Open()) {
660 // Clipboard owns the data you give it
661 wxTheClipboard->SetData(safenew wxTextDataObject(data));
662 wxTheClipboard->Close();
663 }
664
665 return true;
666}
667
668// PRL: should this set other fields of the label selection?
669/// Paste the text on the clipboard to text box

Callers 1

OnCopyFunction · 0.45

Calls 4

swapFunction · 0.50
OpenMethod · 0.45
SetDataMethod · 0.45
CloseMethod · 0.45

Tested by

no test coverage detected