Reputation: 8586
I have a NSWindowController which closes itself by pressing the 'x' key and works great
as you see, very clear my Window, this is the code
-(void)keyDown:(NSEvent *)theEvent{
//If the key is X just closes the window
if ([theEvent.characters.uppercaseString isEqualToString:@"X"]) {
[self.window performClose:self];
}
}
but when I remove the TitleBar or the close control it just stops working...
I want it this way because its required to have my windows without buttons, just to close or do task by shortcuts and commands, in this case the X button to close, how to perform this in a NSWindowController without the close control or titlebar
thanks for the support
Upvotes: 0
Views: 356
Reputation: 2791
with this:
-(void)keyDown:(NSEvent *)theEvent{
//If the key is X just closes the window
if ([theEvent.characters.uppercaseString isEqualToString:@"X"]) {
[self close];
}
}
Upvotes: 1