1
0
mirror of https://github.com/cookiengineer/audacity synced 2025-06-20 22:30:05 +02:00

AudacityApp emits an event when the global clipboard changes

This commit is contained in:
Paul Licameli 2018-02-16 22:25:00 -05:00
parent cee0d35da2
commit dbcf8ae59b
4 changed files with 12 additions and 0 deletions

View File

@ -241,6 +241,8 @@ It handles initialization and termination by subclassing wxApp.
/// Custom events
////////////////////////////////////////////////////////////
wxDEFINE_EVENT( EVT_CLIPBOARD_CHANGE, wxCommandEvent);
DEFINE_EVENT_TYPE(EVT_OPEN_AUDIO_FILE);
wxDEFINE_EVENT(EVT_LANGUAGE_CHANGE, wxCommandEvent);

View File

@ -50,6 +50,11 @@ void QuitAudacity();
extern bool gIsQuitting;
// An event emitted by the application whenever the global clipboard's
// contents change.
wxDECLARE_EXPORTED_EVENT( AUDACITY_DLL_API,
EVT_CLIPBOARD_CHANGE, wxCommandEvent);
// Asynchronous open
DECLARE_EXPORTED_EVENT_TYPE(AUDACITY_DLL_API, EVT_OPEN_AUDIO_FILE, -1);

View File

@ -5232,6 +5232,7 @@ void AudacityProject::EditClipboardByLabel( EditDestFunction action )
// Survived possibility of exceptions. Commit changes to the clipboard now.
newClipboard.Swap(*msClipboard);
wxTheApp->AddPendingEvent( wxCommandEvent{ EVT_CLIPBOARD_CHANGE } );
msClipT0 = regions.front().start;
msClipT1 = regions.back().end;

View File

@ -1,4 +1,5 @@
#include "../AdornedRulerPanel.h"
#include "../AudacityApp.h" // for EVT_CLIPBOARD_CHANGE
#include "../HistoryWindow.h"
#include "../LabelTrack.h"
#include "../Menus.h"
@ -335,6 +336,7 @@ void OnCut(const CommandContext &context)
// Survived possibility of exceptions. Commit changes to the clipboard now.
newClipboard.Swap(*AudacityProject::msClipboard);
wxTheApp->AddPendingEvent( wxCommandEvent{ EVT_CLIPBOARD_CHANGE } );
// Proceed to change the project. If this throws, the project will be
// rolled back by the top level handler.
@ -414,6 +416,7 @@ void OnCopy(const CommandContext &context)
// Survived possibility of exceptions. Commit changes to the clipboard now.
newClipboard.Swap(*AudacityProject::msClipboard);
wxTheApp->AddPendingEvent( wxCommandEvent{ EVT_CLIPBOARD_CHANGE } );
AudacityProject::msClipT0 = selectedRegion.t0();
AudacityProject::msClipT1 = selectedRegion.t1();
@ -754,6 +757,7 @@ void OnSplitCut(const CommandContext &context)
// Survived possibility of exceptions. Commit changes to the clipboard now.
newClipboard.Swap(*AudacityProject::msClipboard);
wxTheApp->AddPendingEvent( wxCommandEvent{ EVT_CLIPBOARD_CHANGE } );
AudacityProject::msClipT0 = selectedRegion.t0();
AudacityProject::msClipT1 = selectedRegion.t1();