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.
This commit is contained in:
Niels Martin Hansen 2009-06-06 02:16:20 +00:00
parent c0586f690c
commit 0f2d39e28f
1 changed files with 12 additions and 5 deletions

View File

@ -422,11 +422,18 @@ void FrameMain::OnMenuOpen (wxMenuEvent &event) {
// Copy/cut/paste // Copy/cut/paste
wxArrayInt sels = SubsBox->GetSelection(); wxArrayInt sels = SubsBox->GetSelection();
bool state = (sels.Count() > 0); bool can_copy = (sels.Count() > 0);
MenuBar->Enable(Menu_Edit_Cut,state);
MenuBar->Enable(Menu_Edit_Copy,state); bool can_paste = true;
MenuBar->Enable(Menu_Edit_Paste,state); if (wxTheClipboard->Open()) {
MenuBar->Enable(Menu_Edit_Paste_Over,state); 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 // Automation menu