appkit

Why isn't applicationShouldOpenUntitledFile being called?

安稳与你 提交于 2019-12-05 20:05:47
问题 I added a applicationShouldOpenUntitledFile method to my application delegate, returning NO as Apple's documentation specifies. However, I'm still getting a new document on startup. What's wrong? @implementation AppDelegate @synthesize window; - (void)applicationDidFinishLaunching:(NSNotification *)aNotification { NSLog( @"This is being called" ); } - (BOOL)applicationShouldOpenUntitledFile:(NSApplication *)sender { NSLog( @"This never is" ); return NO; } @end 回答1: You're running Lion. When

Visual guide of AppKit controls?

杀马特。学长 韩版系。学妹 提交于 2019-12-05 18:59:16
Is there a visual guide to the controls in Mac OS/X AppKit? Take, for instance, the following control that appears at different places in XCode UI: I don't know which AppKit control is that. Any ideas? It looks like a series of NSRadioButton views in an NSMatrix . You can determine the former using Accessibility Inspector, which will tell you that these buttons are of the accessibility class AXRadioButton . You can determine the latter using f-script . (You'll need the new 10.7 injection workflow that isn't in 2.1 yet.) 来源: https://stackoverflow.com/questions/8419660/visual-guide-of-appkit

View and Cell based NSTableView

爷,独闯天下 提交于 2019-12-05 18:20:57
What is the main difference between cell based and view based tableviews in Cocoa. The understanding I have is cell based tableviews are basically used for displaying strings and view based are for custom cells.User events such as dragging rows, selection etc can be handled in view based. cell based tableviews use objectValueForTableColumn: method and view based tables use viewForTableColumn: method. Is my understanding correct?. Or is any other design concerns between these table views. When to go for cell based and when to go for view based. Thanks in advance short answer: A cell can contain

NSURLThumbnailDictionaryKey empty for local file

怎甘沉沦 提交于 2019-12-05 17:39:54
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 with a NSURL pointing to a local file, however, the thumbnails dictionary is empty. Here is an example of

How to intercept keystrokes from within the field editor of an NSTextField?

谁说我不能喝 提交于 2019-12-05 12:40:14
Intro When my custom NSTextField is in "text editing mode" and the field editor has been placed in front of it as firstResponder I no longer get the keystrokes through NSTextField.keyDown(...) . I understand that the keystrokes are now being routed through the field editor . Most online recommendations are to override the following method within the delegate of the custom NSTextField : control(_:textView:doCommandBySelector:) I have indeed overridden this method but it doesn't seem to get called? See code below: class FocusDelegate: NSObject, NSTextFieldDelegate{ func control(control:

NSTextView's insertText method is deprecated in OS X v10.11. What is the replacement?

ⅰ亾dé卋堺 提交于 2019-12-05 12:13:29
I saw in the AppKit API Reference that the insertText method is deprecated in OS X v10.11. What am I supposed to use as a replacement? The documentation says - (void)insertText:(id)aString This method is the means by which text typed by the user enters an NSTextView . See the NSInputManager class and NSTextInput protocol specifications for more information. ... In NSTextInput there is a note: IMPORTANT NSTextInput protocol is slated for deprecation. Please use NSTextInputClient protocol, introduced in OS X v10.5, as described in NSTextInputClient Protocol Reference . In NSTextInputClient

Python 3 No Module Named AppKit

有些话、适合烂在心里 提交于 2019-12-05 12:07:56
I am trying to run an audio file in python from playsound import playsound def main(): playsound('audio.mp3') main() However, I keep getting the following error: File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/playsound.py", line 55, in _playsoundOSX from AppKit import NSSound ImportError: No module named 'AppKit' I am using Python 3.5.4 on macOS 10.12.6. I have tried installing it via pip but I am returned this error: Using cached AppKit-0.2.8.tar.gz Requirement already satisfied: flask in /Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site

Shaving a couple levels of indentation off of an NSOutlineView

本秂侑毒 提交于 2019-12-05 07:13:51
I have an outline view where I don't want to indent the top couple levels (they have a distinctive appearance anyway), but I do want to indent subsequent levels. How can I do this? I've tried overriding -levelForRow: and -levelForItem: to subtract 2 from the return values, but this didn't help. I also tried overriding -frameOfOutlineCellAtRow: to subtract 2 * indentationPerLevel from the frame's width, but that didn't help either, possibly because I'm not showing disclosure triangles. Any thoughts about how I can fix this issue? The outline view is bound to an NSTreeController , which makes it

Debugging Help Book (“The selected topic is currently unavailable”)

被刻印的时光 ゝ 提交于 2019-12-05 02:43:15
问题 Right - so I've created a help book, did all the right things, double-checked my plist and index.html files, and all I get is the notorious The selected topic is currently unavailable. The only entry in Console when attempting to open the help book is a plain 3/8/15 1:23:42.467 PM HelpViewer[35015]: Couldn't find book with this ID: (null) Not too helpful. Where to go from here? Are there any debugging techniques for Apple Help? Logging to turn on? Anything..? 回答1: Just struggled a few hours

Autorelease pools in appkit applications

橙三吉。 提交于 2019-12-04 23:06:35
I'm having difficulties to understand exactly WHEN autorelease pools are created and released in AppKit apps. For example, if I have an ApplicationController class that overrides init, is there an autorelease pool that gets created before it starts and gets drained after it ends? The main thread in an AppKit application runs an NSRunLoop to process events. NSRunLoop creates a new autorelease pool every time it processes a new event (or timer) and drains it once control flow has returned to the NSRunLoop. So in essence, every pass through the run loop has a fresh autorelease pool. 来源: https:/