Application-wide hotkeys + feed edit modal sheet

This commit is contained in:
relikd
2018-08-03 23:53:22 +02:00
parent f27b54af4f
commit 8080af1a0f
10 changed files with 368 additions and 64 deletions

57
baRSS/AppHook.m Normal file
View File

@@ -0,0 +1,57 @@
//
// The MIT License (MIT)
// Copyright (c) 2018 Oleg Geier
//
// Permission is hereby granted, free of charge, to any person obtaining a copy of
// this software and associated documentation files (the "Software"), to deal in
// the Software without restriction, including without limitation the rights to
// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
// of the Software, and to permit persons to whom the Software is furnished to do
// so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all
// copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
// SOFTWARE.
#import "AppHook.h"
static NSEventModifierFlags fnKeyFlags = NSEventModifierFlagShift | NSEventModifierFlagControl | NSEventModifierFlagOption | NSEventModifierFlagCommand | NSEventModifierFlagFunction;
@implementation AppHook
- (void) sendEvent:(NSEvent *)event {
if ([event type] == NSEventTypeKeyDown) {
NSEventModifierFlags flags = (event.modifierFlags & fnKeyFlags); // ignore caps lock, etc.
unichar key = [event.characters characterAtIndex:0]; // charactersIgnoringModifiers
if (flags == NSEventModifierFlagCommand) {
switch (key) {
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wundeclared-selector"
case 'z': if ([self sendAction:@selector(undo:) to:nil from:self]) return; break;
#pragma clang diagnostic pop
case 'x': if ([self sendAction:@selector(cut:) to:nil from:self]) return; break;
case 'c': if ([self sendAction:@selector(copy:) to:nil from:self]) return; break;
case 'v': if ([self sendAction:@selector(paste:) to:nil from:self]) return; break;
case 'a': if ([self sendAction:@selector(selectAll:) to:nil from:self]) return; break;
case 'q': if ([self sendAction:@selector(terminate:) to:nil from:self]) return; break;
case 'w': if ([self sendAction:@selector(performClose:) to:nil from:self]) return; break;
}
} else if (flags == (NSEventModifierFlagCommand | NSEventModifierFlagShift)) {
if (key == 'z') {
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wundeclared-selector"
if ([self sendAction:@selector(redo:) to:nil from:self])
return;
#pragma clang diagnostic pop
}
}
}
[super sendEvent:event];
}
@end