summaryrefslogtreecommitdiff
path: root/src/wx/timecode.cc
diff options
context:
space:
mode:
Diffstat (limited to 'src/wx/timecode.cc')
-rw-r--r--src/wx/timecode.cc32
1 files changed, 32 insertions, 0 deletions
diff --git a/src/wx/timecode.cc b/src/wx/timecode.cc
index 63c119a18..d4a8a5074 100644
--- a/src/wx/timecode.cc
+++ b/src/wx/timecode.cc
@@ -23,6 +23,8 @@
#include "timecode.h"
#include "wx_util.h"
#include "lib/util.h"
+#include <dcp/scope_guard.h>
+#include <wx/clipbrd.h>
using std::string;
@@ -79,6 +81,7 @@ TimecodeBase::TimecodeBase (wxWindow* parent, bool set_button)
for (auto control: _controls) {
control->Bind(wxEVT_TEXT, boost::bind(&TimecodeBase::changed, this, _1));
+ control->Bind(wxEVT_TEXT_PASTE, boost::bind(&TimecodeBase::paste, this, _1));
}
if (_set_button) {
_set_button->Bind (wxEVT_BUTTON, boost::bind (&TimecodeBase::set_clicked, this));
@@ -127,6 +130,35 @@ TimecodeBase::changed(wxCommandEvent& ev)
}
}
+
+void
+TimecodeBase::paste(wxClipboardTextEvent& ev)
+{
+ if (!wxTheClipboard->Open()) {
+ return;
+ }
+
+ dcp::ScopeGuard sg = []() {
+ wxTheClipboard->Close();
+ };
+
+ if (wxTheClipboard->IsSupported(wxDF_TEXT) || wxTheClipboard->IsSupported(wxDF_UNICODETEXT)) {
+ wxTextDataObject clipboard;
+ wxTheClipboard->GetData(clipboard);
+ auto contents = clipboard.GetText();
+ if (contents.Length() == 8 && contents.IsNumber()) {
+ _hours->SetValue(contents.Mid(0, 2));
+ _minutes->SetValue(contents.Mid(2, 2));
+ _seconds->SetValue(contents.Mid(4, 2));
+ _frames->SetValue(contents.Mid(6, 2));
+ return;
+ }
+ }
+
+ ev.Skip();
+}
+
+
void
TimecodeBase::set_clicked ()
{