nsapplication

How to know if a NSWindow is fullscreen in Mac OS X Lion?

北城以北 提交于 2019-11-30 01:16:47
问题 I guess I should check if [NSApplication presentationOptions] contains NSFullScreenModeApplicationPresentationOptions , but how do I achieve that? EDIT: using [NSApplication presentationOptions] doesn't work as in my document-based app there might be some documents in fullscreen and others not. I'm now looking for another solution. I'm wondering why there isn't a property called [NSWindow isFullscreen] or something like that. 回答1: I was just looking for a solution myself and based on Matthieu

Subclass NSApplication in Swift

余生长醉 提交于 2019-11-29 12:41:03
问题 I created NSApplication subclass: class MyApplication: NSApplication { override func sendEvent(theEvent: NSEvent) { if theEvent.type == NSEventType.KeyUp && (theEvent.modifierFlags & .CommandKeyMask).rawValue != 0 { self.keyWindow?.sendEvent(theEvent) } else { super.sendEvent(theEvent) } } } After that, I changed "Principal class" in Info.plist to MyApplication and at the end in the Application Scene in Main.storyboard, I changed Application to MyApplication, too. When I run application I get

How to programmatically make cocoa application active

ε祈祈猫儿з 提交于 2019-11-27 12:56:11
问题 I've got a background process that makes a transparent window appear when a hotkey is pressed: [window makeKeyAndOrderFront:nil]; [[content animator] setAlphaValue:1.0]; // alpha was 0.0 ... the window shows up fine & in front of the other windows (as I want it to), however until I manually click the window whatever application was active when the window appears remains active. I was expecting the 'makeKeyAndOrderFront' to make the application active as well, however adding a NSLog line to my