mirror of
https://github.com/objective-see/BlockBlock.git
synced 2026-03-22 07:02:39 +00:00
57ca40fc7f
BlockBlock v1.0 (beta)
74 lines
2.0 KiB
Objective-C
Executable File
74 lines
2.0 KiB
Objective-C
Executable File
//
|
|
// file: NSApplicationKeyEvents.h
|
|
// project: BlockBlock (shared)
|
|
// description: adds support for keyboard shortcuts (header)
|
|
//
|
|
// created by Patrick Wardle
|
|
// copyright (c) 2018 Objective-See. All rights reserved.
|
|
//
|
|
|
|
#import "NSApplicationKeyEvents.h"
|
|
|
|
@implementation NSApplicationKeyEvents
|
|
|
|
//to enable copy/paste etc even though we don't have an 'Edit' menu
|
|
// details: http://stackoverflow.com/questions/970707/cocoa-keyboard-shortcuts-in-dialog-without-an-edit-menu
|
|
-(void) sendEvent:(NSEvent *)event
|
|
{
|
|
//keydown?
|
|
if([event type] == NSEventTypeKeyDown)
|
|
{
|
|
//command?
|
|
if(([event modifierFlags] & NSEventModifierFlagDeviceIndependentFlagsMask) == NSEventModifierFlagCommand)
|
|
{
|
|
//+c
|
|
// copy
|
|
if(YES == [[event charactersIgnoringModifiers] isEqualToString:@"c"])
|
|
{
|
|
//copy
|
|
if([self sendAction:@selector(copy:) to:nil from:self])
|
|
{
|
|
return;
|
|
}
|
|
}
|
|
|
|
//+v
|
|
// paste
|
|
else if ([[event charactersIgnoringModifiers] isEqualToString:@"v"])
|
|
{
|
|
//paste
|
|
if([self sendAction:@selector(paste:) to:nil from:self])
|
|
{
|
|
return;
|
|
}
|
|
}
|
|
|
|
//+x
|
|
// cut
|
|
else if ([[event charactersIgnoringModifiers] isEqualToString:@"x"])
|
|
{
|
|
//cut
|
|
if([self sendAction:@selector(cut:) to:nil from:self])
|
|
{
|
|
return;
|
|
}
|
|
}
|
|
|
|
//+a
|
|
// select all
|
|
else if([[event charactersIgnoringModifiers] isEqualToString:@"a"])
|
|
{
|
|
if ([self sendAction:@selector(selectAll:) to:nil from:self])
|
|
{
|
|
return;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
//super
|
|
[super sendEvent:event];
|
|
}
|
|
|
|
@end
|