From 14274a767211c7fcd19ec7b4dce95c2e1777961d Mon Sep 17 00:00:00 2001 From: Thomas Goyne Date: Mon, 12 Mar 2012 23:34:25 +0000 Subject: [PATCH] Forward Cut/Copy/Paste to all text areas, not just the main subs edit box Originally committed to SVN as r6576. --- aegisub/src/command/edit.cpp | 34 +++++++++++++++++++--------------- 1 file changed, 19 insertions(+), 15 deletions(-) diff --git a/aegisub/src/command/edit.cpp b/aegisub/src/command/edit.cpp index f8ec605d4..4ef3dc266 100644 --- a/aegisub/src/command/edit.cpp +++ b/aegisub/src/command/edit.cpp @@ -95,11 +95,17 @@ struct edit_line_copy : public validate_sel_nonempty { STR_HELP("Copy subtitles") void operator()(agi::Context *c) { - if (c->parent->FindFocus() == c->editBox) { - c->editBox->Copy(); - return; - } - c->subsGrid->CopyLines(c->subsGrid->GetSelection()); + // Ideally we'd let the control's keydown handler run and only deal + // with the events not processed by it, but that doesn't seem to be + // possible with how wx implements key event handling - the native + // platform processing is evoked only if the wx event is unprocessed, + // and there's no way to do something if the native platform code leaves + // it unprocessed + + if (wxTextEntryBase *ctrl = dynamic_cast(c->parent->FindFocus())) + ctrl->Copy(); + else + c->subsGrid->CopyLines(c->subsGrid->GetSelection()); } }; @@ -112,11 +118,10 @@ struct edit_line_cut: public validate_sel_nonempty { STR_HELP("Cut subtitles") void operator()(agi::Context *c) { - if (c->parent->FindFocus() == c->editBox) { - c->editBox->Cut(); - return; - } - c->subsGrid->CutLines(c->subsGrid->GetSelection()); + if (wxTextEntryBase *ctrl = dynamic_cast(c->parent->FindFocus())) + ctrl->Cut(); + else + c->subsGrid->CutLines(c->subsGrid->GetSelection()); } }; @@ -316,11 +321,10 @@ struct edit_line_paste : public Command { } void operator()(agi::Context *c) { - if (c->parent->FindFocus() == c->editBox) { - c->editBox->Paste(); - return; - } - c->subsGrid->PasteLines(c->subsGrid->GetFirstSelRow()); + if (wxTextEntryBase *ctrl = dynamic_cast(c->parent->FindFocus())) + ctrl->Paste(); + else + c->subsGrid->PasteLines(c->subsGrid->GetFirstSelRow()); } };