Copy the selected text in the text box @return true if text is selected in text box, false otherwise
| 640 | /// Copy the selected text in the text box |
| 641 | /// @return true if text is selected in text box, false otherwise |
| 642 | bool 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 |