1
0
mirror of https://github.com/cookiengineer/audacity synced 2025-08-09 08:31:13 +02:00

Rework of commit b4a0be9

See comments 6-9 in bug #2642 for the problem it caused.
This commit is contained in:
Leland Lucius 2021-01-22 15:16:38 -06:00
parent 4e6e3c2089
commit 50e803a974
2 changed files with 44 additions and 2 deletions

View File

@ -723,8 +723,10 @@ CommandListEntry *CommandManager::NewIdentifier(const CommandID & nameIn,
else if (name == wxT("About"))
entry->id = wxID_ABOUT;
// This is a fix for bugs 1300 and 1579. Using the wx provides IDs
// allows wx to handle them in an macOS way.
#if defined(BE_CAREFUL)
// Don't be tempted to do this unless you're willing to change how
// HandleMenuID() decides if a menu action should be performed.
// (see comments 6-9 in bug #2642 for symptoms)
else if (name == wxT("Copy"))
entry->id = wxID_COPY;
else if (name == wxT("Cut"))
@ -735,6 +737,8 @@ CommandListEntry *CommandManager::NewIdentifier(const CommandID & nameIn,
entry->id = wxID_PASTE;
else if (name == wxT("SelectAll"))
entry->id = wxID_SELECTALL;
#endif
#endif
entry->name = name;

View File

@ -508,6 +508,42 @@ int FileDialog::ShowModal()
SetupExtraControls(sPanel);
// PRL:
// Hack for bugs 1300/1579: Intercept key down events, implementing
// copy/cut/paste, by invoking appropriate selectors. This is done
// because we do not use the wxWidgets IDs for the menu equivalents.
id handler;
if (wxTheClipboard->IsSupported(wxDF_UNICODETEXT)) {
handler = [
NSEvent addLocalMonitorForEventsMatchingMask:NSKeyDownMask
handler:^NSEvent *(NSEvent *event)
{
auto app = [NSApplication sharedApplication];
if ([event modifierFlags] & NSCommandKeyMask)
{
auto chars = [event charactersIgnoringModifiers];
if ([chars isEqualToString:@"a"])
{
[app sendAction:@selector(selectAll:) to:nil from:nil];
}
else if ([chars isEqualToString:@"c"])
{
[app sendAction:@selector(copy:) to:nil from:nil];
}
else if ([chars isEqualToString:@"x"])
{
[app sendAction:@selector(cut:) to:nil from:nil];
}
else if ([chars isEqualToString:@"v"])
{
[app sendAction:@selector(paste:) to:nil from:nil];
}
}
return event;
}
];
}
// makes things more convenient:
[sPanel setCanCreateDirectories:YES];
[sPanel setMessage:cf.AsNSString()];
@ -540,6 +576,8 @@ int FileDialog::ShowModal()
[sPanel setNameFieldStringValue:file.AsNSString()];
returnCode = [sPanel runModal];
ModalFinishedCallback(sPanel, returnCode);
if (wxTheClipboard->IsSupported(wxDF_UNICODETEXT))
[NSEvent removeMonitor:handler];
}
else
{