I have an LSUIElement
application that displays a menubar status item. The application can display a dialog window that contains a text field.
If the u
Here's Travis' answer as C# for use with Xamarin.Mac:
public override bool PerformKeyEquivalent (AppKit.NSEvent e)
{
if (e.Type == NSEventType.KeyDown) {
var inputKey = e.CharactersIgnoringModifiers.ToLower ();
if ( (e.ModifierFlags & NSEventModifierMask.DeviceIndependentModifierFlagsMask) == NSEventModifierMask.CommandKeyMask
|| (e.ModifierFlags & NSEventModifierMask.DeviceIndependentModifierFlagsMask) == (NSEventModifierMask.CommandKeyMask | NSEventModifierMask.AlphaShiftKeyMask)) {
switch (inputKey) {
case "x":
NSApplication.SharedApplication.SendAction (new Selector ("cut:"), null, this);
return true;
case "c":
NSApplication.SharedApplication.SendAction (new Selector ("copy:"), null, this);
return true;
case "v":
NSApplication.SharedApplication.SendAction (new Selector ("paste:"), null, this);
return true;
case "z":
NSApplication.SharedApplication.SendAction (new Selector ("undo:"), null, this);
return true;
case "a":
NSApplication.SharedApplication.SendAction (new Selector ("selectAll:"), null, this);
return true;
}
} else if ( (e.ModifierFlags & NSEventModifierMask.DeviceIndependentModifierFlagsMask) == (NSEventModifierMask.CommandKeyMask | NSEventModifierMask.ShiftKeyMask)
|| (e.ModifierFlags & NSEventModifierMask.DeviceIndependentModifierFlagsMask) == (NSEventModifierMask.CommandKeyMask | NSEventModifierMask.ShiftKeyMask | NSEventModifierMask.AlphaShiftKeyMask)) {
switch (inputKey) {
case "z":
NSApplication.SharedApplication.SendAction (new Selector ("redo:"), null, this);
return true;
}
}
}
return base.PerformKeyEquivalent(e);
}