appkit

Disable Full Keyboard Access for App

╄→尐↘猪︶ㄣ 提交于 2019-12-25 03:14:16
问题 Can "Full Keyboard Access" (System Prefs -> Keyboard -> (Radio) All Controls) be controlled with some API? It causes major issues when this thing is on in my app (like buttons not working as expected etc ... it has some custom UI) Regards, Erik 回答1: Override nextValidKeyView and previousValidKeyView in your custom view to return something sane, or set the view's nextKeyView and previousKeyView to specific views if detecting valid key views automatically isn't possible. If Full Keyboard Access

How to create a custom NSTableCellView from a NIB?

瘦欲@ 提交于 2019-12-24 22:42:56
问题 I'm new to Swift and I am struggling with NSTableView! I'm trying to create a custom NSTableCellView from a NIB. I want to load the cell from a NIB because: - it will be reused in multiple columns and multiple table-views - it will be visually and functionally complex (relatively) - it is likely to evolve during development I'm able to load the cell in my table view but I'm getting a "Failed to connect outlet from... missing setter or instance variable" error in the debug area when I try to

Creating AppKit elements in a SpriteKit game

与世无争的帅哥 提交于 2019-12-24 14:43:17
问题 The title of the question really says it all. I am trying to tie in AppKit elements like buttons and other controls into a OS X SpriteKit game. My understanding is that AppKit elements can be placed on top of SKScenes, but how does this work? Would this be handled via an NSView? How does the layer get created in SpriteKit or is this a separate process altogether? 回答1: All AppKit UI elements are subclasses of NSResponder and most are subclasses of NSView This means like any other Cocoa app,

How to send and receive NSAppleEventDescriptor when using NSWorkspace to open URLs between apps?

放肆的年华 提交于 2019-12-24 07:29:14
问题 NSWorkspace has the method open(_:withAppBundleIdentifier: [...] ) : Opens one or more files from an array of URLs. func open(_ urls: [URL], withAppBundleIdentifier bundleIdentifier: String?, options: NSWorkspace.LaunchOptions = [], additionalEventParamDescriptor descriptor: NSAppleEventDescriptor?, launchIdentifiers identifiers:) -> Bool The NSApplicationDelegate of the app you want to open has corresponding methods that are called to open the URL(s) you provide: func application(_ sender:

How to send and receive NSAppleEventDescriptor when using NSWorkspace to open URLs between apps?

倾然丶 夕夏残阳落幕 提交于 2019-12-24 07:29:12
问题 NSWorkspace has the method open(_:withAppBundleIdentifier: [...] ) : Opens one or more files from an array of URLs. func open(_ urls: [URL], withAppBundleIdentifier bundleIdentifier: String?, options: NSWorkspace.LaunchOptions = [], additionalEventParamDescriptor descriptor: NSAppleEventDescriptor?, launchIdentifiers identifiers:) -> Bool The NSApplicationDelegate of the app you want to open has corresponding methods that are called to open the URL(s) you provide: func application(_ sender:

Removing undo actions for a WebView's NSUndoManager

此生再无相见时 提交于 2019-12-23 12:28:04
问题 I have several WebViews that I swap in and out of my view hierarchy. Some of these WebViews contain form fields, so I implement the editingDelegate to provide the NSUndoManager for my document. The problem is that any typing done in the WebView generates actions that are placed on the undo stack. After the view is removed from the hierarchy, the actions are still in the undo stack. At that point, if a user uses Cmd-Z to "Undo Typing", an exception is thrown because -undoEditing: is being sent

NSTableView unhideRowsAtIndexes crashes

Deadly 提交于 2019-12-23 05:45:12
问题 I am creating a grouped NSTableView that loads just fine and with all my objects the way I want to. I also created the possibility to collapse entire group sections (the rows between group rows) and I use the hideRowsAtIndexes:withAnimation: and unhideRowsAtIndexes:withAnimation: that were added to NSTableView ( https://developer.apple.com/library/mac/releasenotes/AppKit/RN-AppKit/#10_11TableView). Hiding always seem to work, but unhiding crashes for some rows. The last row hides and unhides

NSTextField clicked link colour

不想你离开。 提交于 2019-12-22 17:04:11
问题 I have an NSTextField that contains an NSAttributedString which itself contains a clickable link. I've change the colour of the link for my own styling, however when I click on it it becomes blue and underlined. How can I stop this? 回答1: Seems that I'm not the only one with this problem, and there's a handy class to solve it: https://github.com/laevandus/NSTextFieldHyperlinks 回答2: This ( http://developer.apple.com/library/mac/#qa/qa1487/_index.html ) may help you. It will show you how to set

NSSharingService on mountain lion without sharing window

左心房为你撑大大i 提交于 2019-12-22 09:09:41
问题 On mountain lion, I try the new sharing possiblities with the NSSharingService class of AppKit.framework Everything goes fine with this kind of code NSArray* array = @[ @"myText", [NSImage imageNamed:@"myImageFile"] ]; NSSharingService* sharingServiceFB = [NSSharingService sharingServiceNamed:NSSharingServiceNamePostOnFacebook]; [sharingServiceFB performWithItems:array]; But I'd like to do the same without the sharing window generated by the performWithItems function. As I'm considering that

NSURLThumbnailDictionaryKey empty for local file

Deadly 提交于 2019-12-22 08:44:43
问题 I want to get a thumbnail representation of a file I have to display in my app. I'm using NSURL here: NSDictionary *thumbnails = nil; BOOL success = [fileURL getResourceValue:&thumbnails forKey:NSURLThumbnailDictionaryKey error: &error]; This works fine if I am connected to iCloud, and the URL is a link to a file stored in iCloud. The fileURL is something like: file:///Users/me/Library/Mobile%20Documents/BJXXGLR9R3~com~myapp~icloud/FileStorage/contact-page%20copy.png If I use the same code