From 8be4101d706079569697cea5dc483a3afd8126e1 Mon Sep 17 00:00:00 2001 From: Niels Martin Hansen Date: Sat, 6 Jun 2009 02:16:20 +0000 Subject: [PATCH] Fix #787, make the Paste and Paste Over commands in the Edit menu sensitive to the current format on the clipboard and only enable them if plain text is a supported format. They will also be enabled if the clipboard fails to open, as a safety device. Originally committed to SVN as r3021. --- aegisub/src/frame_main_events.cpp | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/aegisub/src/frame_main_events.cpp b/aegisub/src/frame_main_events.cpp index 12a660d8e..bcd6c1ff0 100644 --- a/aegisub/src/frame_main_events.cpp +++ b/aegisub/src/frame_main_events.cpp @@ -422,11 +422,18 @@ void FrameMain::OnMenuOpen (wxMenuEvent &event) { // Copy/cut/paste wxArrayInt sels = SubsBox->GetSelection(); - bool state = (sels.Count() > 0); - MenuBar->Enable(Menu_Edit_Cut,state); - MenuBar->Enable(Menu_Edit_Copy,state); - MenuBar->Enable(Menu_Edit_Paste,state); - MenuBar->Enable(Menu_Edit_Paste_Over,state); + bool can_copy = (sels.Count() > 0); + + bool can_paste = true; + if (wxTheClipboard->Open()) { + can_paste = wxTheClipboard->IsSupported(wxDF_TEXT); + wxTheClipboard->Close(); + } + + MenuBar->Enable(Menu_Edit_Cut,can_copy); + MenuBar->Enable(Menu_Edit_Copy,can_copy); + MenuBar->Enable(Menu_Edit_Paste,can_paste); + MenuBar->Enable(Menu_Edit_Paste_Over,can_copy&&can_paste); } // Automation menu