mirror of
https://github.com/cookiengineer/audacity
synced 2025-11-23 17:30:17 +01:00
Bug 1579 - Mac: Cut/Copy from file save dialogs using shortcuts does not work
And Bug 1300 - Mac: COMMAND + V paste limitations in standard file save dialogs
This commit is contained in:
@@ -722,6 +722,19 @@ CommandListEntry *CommandManager::NewIdentifier(const CommandID & nameIn,
|
|||||||
entry->id = wxID_EXIT;
|
entry->id = wxID_EXIT;
|
||||||
else if (name == wxT("About"))
|
else if (name == wxT("About"))
|
||||||
entry->id = wxID_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.
|
||||||
|
else if (name == wxT("Copy"))
|
||||||
|
entry->id = wxID_CUT;
|
||||||
|
else if (name == wxT("Cut"))
|
||||||
|
entry->id = wxID_COPY;
|
||||||
|
else if (name == wxT("Delete"))
|
||||||
|
entry->id = wxID_CLEAR;
|
||||||
|
else if (name == wxT("Paste"))
|
||||||
|
entry->id = wxID_PASTE;
|
||||||
|
else if (name == wxT("SelectAll"))
|
||||||
|
entry->id = wxID_SELECTALL;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
entry->name = name;
|
entry->name = name;
|
||||||
|
|||||||
@@ -508,47 +508,6 @@ int FileDialog::ShowModal()
|
|||||||
|
|
||||||
SetupExtraControls(sPanel);
|
SetupExtraControls(sPanel);
|
||||||
|
|
||||||
// PRL:
|
|
||||||
// Hack for bug 1300: intercept key down events, implement a
|
|
||||||
// Command+V handler, but it's a bit crude. It always pastes
|
|
||||||
// the entire text field, ignoring the insertion cursor, and ignoring
|
|
||||||
// which control really has the focus.
|
|
||||||
id handler;
|
|
||||||
if (wxTheClipboard->IsSupported(wxDF_UNICODETEXT)) {
|
|
||||||
handler = [
|
|
||||||
NSEvent addLocalMonitorForEventsMatchingMask:NSKeyDownMask
|
|
||||||
handler:^NSEvent *(NSEvent *event)
|
|
||||||
{
|
|
||||||
if ([event modifierFlags] & NSCommandKeyMask)
|
|
||||||
{
|
|
||||||
auto chars = [event charactersIgnoringModifiers];
|
|
||||||
auto character = [chars characterAtIndex:0];
|
|
||||||
if (character == 'v')
|
|
||||||
{
|
|
||||||
if (wxTheClipboard->Open()) {
|
|
||||||
wxTextDataObject data;
|
|
||||||
wxTheClipboard->GetData(data);
|
|
||||||
wxTheClipboard->Close();
|
|
||||||
wxString text = data.GetText();
|
|
||||||
auto rawText = text.utf8_str();
|
|
||||||
auto length = text.Length();
|
|
||||||
NSString *myString = [[NSString alloc]
|
|
||||||
initWithBytes:rawText.data()
|
|
||||||
length: rawText.length()
|
|
||||||
encoding: NSUTF8StringEncoding
|
|
||||||
];
|
|
||||||
[sPanel setNameFieldStringValue:myString];
|
|
||||||
[myString release];
|
|
||||||
return nil;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return event;
|
|
||||||
}
|
|
||||||
];
|
|
||||||
}
|
|
||||||
|
|
||||||
// makes things more convenient:
|
// makes things more convenient:
|
||||||
[sPanel setCanCreateDirectories:YES];
|
[sPanel setCanCreateDirectories:YES];
|
||||||
[sPanel setMessage:cf.AsNSString()];
|
[sPanel setMessage:cf.AsNSString()];
|
||||||
@@ -581,8 +540,6 @@ int FileDialog::ShowModal()
|
|||||||
[sPanel setNameFieldStringValue:file.AsNSString()];
|
[sPanel setNameFieldStringValue:file.AsNSString()];
|
||||||
returnCode = [sPanel runModal];
|
returnCode = [sPanel runModal];
|
||||||
ModalFinishedCallback(sPanel, returnCode);
|
ModalFinishedCallback(sPanel, returnCode);
|
||||||
if (wxTheClipboard->IsSupported(wxDF_UNICODETEXT))
|
|
||||||
[NSEvent removeMonitor:handler];
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user