Initial commit.
This commit is contained in:
@@ -0,0 +1,50 @@
|
||||
#import <Cocoa/Cocoa.h>
|
||||
#import <Carbon/Carbon.h>
|
||||
|
||||
#import "MenulessWindow.h"
|
||||
#include "Helpers.h"
|
||||
|
||||
/* TODO: Either change name or move some of the configuration out of the
|
||||
* init, decide whether this is a generic menuless window or not. */
|
||||
@implementation MenulessWindow
|
||||
|
||||
- (instancetype)initWithContentViewController:(NSViewController *)contentViewController {
|
||||
self = [super initWithContentRect:NSMakeRect(0, 0, 100, 100)
|
||||
styleMask:NSWindowStyleMaskTitled|NSWindowStyleMaskClosable
|
||||
backing:NSBackingStoreBuffered
|
||||
defer:false];
|
||||
if(self) {
|
||||
[super setContentViewController:contentViewController];
|
||||
[self setTitle:@""];
|
||||
[self setTitlebarAppearsTransparent:YES];
|
||||
[self setCollectionBehavior:NSWindowCollectionBehaviorManaged];
|
||||
[self setReleasedWhenClosed:NO];
|
||||
[self setHidesOnDeactivate:NO];
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
- (BOOL)performKeyEquivalent:(NSEvent *)event {
|
||||
NSEventModifierFlags modifiers = [event modifierFlags];
|
||||
unsigned short key = [event keyCode];
|
||||
|
||||
if([event type] == NSEventTypeKeyDown) {
|
||||
if(modsContains(NSEventModifierFlagCommand, modifiers) &&
|
||||
key == kVK_ANSI_W)
|
||||
{
|
||||
[self performClose:nil];
|
||||
return YES;
|
||||
}
|
||||
}
|
||||
|
||||
return NO;
|
||||
}
|
||||
|
||||
/* - (instancetype)init { */
|
||||
/* self = [super init]; */
|
||||
/* if(self) { */
|
||||
/* } */
|
||||
/* return self; */
|
||||
/* } */
|
||||
|
||||
@end
|
||||
Reference in New Issue
Block a user