cocoa

How to get list of all applications currently running and visible in Dock for Mac OS X programming?

心不动则不痛 提交于 2021-01-21 07:32:15
问题 I need to know which applications are running and have an active window. Something similar must be what's in the 'command + tab' hotkey switcher. When I run some code like this: NSWorkspace * ws = [NSWorkspace sharedWorkspace]; NSArray * apps = [ws runningApplications]; NSLog (@"%@", apps); I get this in my log: "<NSRunningApplication: 0x6080001052b0 (com.apple.loginwindow - 66)>", "<NSRunningApplication: 0x608000105340 (com.apple.systemuiserver - 285)>", "<NSRunningApplication:

How to collapse an NSSplitView pane with animation while using Auto Layout?

僤鯓⒐⒋嵵緔 提交于 2021-01-21 07:27:26
问题 I've tried everything I can think of, including all the suggestions I've found here on SO and on other mailing lists, but I cannot figure out how to programmatically collapse an NSSplitView pane with an animation while Auto Layout is on. Here's what I have right now (written in Swift for fun), but it falls down in multiple ways: @IBAction func toggleSourceList(sender: AnyObject?) { let isOpen = !splitView.isSubviewCollapsed(sourceList.view.superview!) let position = (isOpen ? 0 : self

SwiftUI: Detect finger position on Mac trackpad

前提是你 提交于 2021-01-20 20:10:03
问题 I'm making a SwiftUI app for macOS and I'd like to use the trackpad as an (x, y) input by detecting the position of the user's fingers. I wanna be able to detect multiple fingers that are resting on the trackpad (not dragging). How do I do that? A similar question has been asked before, but I'm asking again because that was from nearly 10 years ago, the answers are all in Obj-C (one in Swift 3), and I'm wondering if there's an updated methodology. Most importantly, I've no clue how to

SwiftUI: Detect finger position on Mac trackpad

若如初见. 提交于 2021-01-20 20:09:51
问题 I'm making a SwiftUI app for macOS and I'd like to use the trackpad as an (x, y) input by detecting the position of the user's fingers. I wanna be able to detect multiple fingers that are resting on the trackpad (not dragging). How do I do that? A similar question has been asked before, but I'm asking again because that was from nearly 10 years ago, the answers are all in Obj-C (one in Swift 3), and I'm wondering if there's an updated methodology. Most importantly, I've no clue how to

SwiftUI: Detect finger position on Mac trackpad

人走茶凉 提交于 2021-01-20 20:08:31
问题 I'm making a SwiftUI app for macOS and I'd like to use the trackpad as an (x, y) input by detecting the position of the user's fingers. I wanna be able to detect multiple fingers that are resting on the trackpad (not dragging). How do I do that? A similar question has been asked before, but I'm asking again because that was from nearly 10 years ago, the answers are all in Obj-C (one in Swift 3), and I'm wondering if there's an updated methodology. Most importantly, I've no clue how to

SwiftUI: Detect finger position on Mac trackpad

两盒软妹~` 提交于 2021-01-20 20:06:35
问题 I'm making a SwiftUI app for macOS and I'd like to use the trackpad as an (x, y) input by detecting the position of the user's fingers. I wanna be able to detect multiple fingers that are resting on the trackpad (not dragging). How do I do that? A similar question has been asked before, but I'm asking again because that was from nearly 10 years ago, the answers are all in Obj-C (one in Swift 3), and I'm wondering if there's an updated methodology. Most importantly, I've no clue how to

How do I access images (for document icons) in an asset catalog in the Xcode 5 product preference editor

 ̄綄美尐妖づ 提交于 2021-01-20 19:16:15
问题 I think I'm literally on the last step before submitting a new Mac app, and I've been banging my head against a wall for the past few hours on what I think should be really, really easy. I've designed document icons for the two different types of icons my app creates and works with. I created a new "Icon" in Images.xcassets, and dropped the appropriate files into the drop zones. In the product editor -> Info, I go to where the document type information is, but when I try to enter in the icon

How do I access images (for document icons) in an asset catalog in the Xcode 5 product preference editor

三世轮回 提交于 2021-01-20 19:14:28
问题 I think I'm literally on the last step before submitting a new Mac app, and I've been banging my head against a wall for the past few hours on what I think should be really, really easy. I've designed document icons for the two different types of icons my app creates and works with. I created a new "Icon" in Images.xcassets, and dropped the appropriate files into the drop zones. In the product editor -> Info, I go to where the document type information is, but when I try to enter in the icon

How do I access images (for document icons) in an asset catalog in the Xcode 5 product preference editor

拜拜、爱过 提交于 2021-01-20 19:12:36
问题 I think I'm literally on the last step before submitting a new Mac app, and I've been banging my head against a wall for the past few hours on what I think should be really, really easy. I've designed document icons for the two different types of icons my app creates and works with. I created a new "Icon" in Images.xcassets, and dropped the appropriate files into the drop zones. In the product editor -> Info, I go to where the document type information is, but when I try to enter in the icon

Cannot read property 'keyCode' 'character' Assertion failure when detect modifier key + numeric key

試著忘記壹切 提交于 2021-01-16 03:51:42
问题 class func addGlobalMonitorForEvents(matching mask: NSEvent.EventTypeMask, handler block: @escaping (NSEvent) -> Void) -> Any?{ print("this inside addGlobalMonitorForEvents") } NSEvent.addGlobalMonitorForEvents(matching: .flagsChanged) { switch $0.modifierFlags.intersection(.deviceIndependentFlagsMask) { case [.shift]: print("shift key is pressed") print("key code is \($0.keyCode))") case [.control] where $0.characters == "1": print("control key is pressed") print("characters is \($0