appkit

How to make action to close NSPopover?

北城以北 提交于 2019-12-08 14:58:14
问题 Hi I implemented an NSPopover in one of my apps, but the popover will not close. I'm guessing that it should close once I click something else, but its not. I know that there's a close popover action but that only works for a different button. How can I make it look to see that the popover is open and when it is open to close the popover when I press the same button? 回答1: I solved the problem! First go ahead and click your .xib file. Where you see the first responder box and files owner -

collectionView(_:didDeselectItemsAt:) is never called

自古美人都是妖i 提交于 2019-12-08 09:38:50
问题 For some reason, my NSCollectionView (which uses a custom layout that I wrote) calls its delegate's collectionView(_:didSelectItemsAt:) function when I click an item, but not that same delegate's collectionView(_:didDeselectItemsAt:) when I click off it. Here's my basic setup: class MyCollectionViewContainer: NSViewController { fileprivate lazy var collectionView: NSCollectionView = { let collectionView = NSCollectionView() collectionView.delegate = self collectionView.dataSource = self

Does NSPasteboard retain owner objects?

不羁岁月 提交于 2019-12-08 07:10:48
问题 You can call NSPasteboard like this: [pboard declareTypes:types owner:self]; Which means that the pasteboard will later ask the owner to supply data for a type as needed. However, what I can't find from the docs (and maybe I've missed something bleeding obvious), is whether or not owner is retained. In practice what's worrying me is if the owner is a weak reference, it could be deallocated, causing a crash if the pasteboard then tries to request data from it. Note: I should probably clarify

Why does a CATransform3DMakeRotation not take (0,0,1) as rotating around the Z-axis?

落花浮王杯 提交于 2019-12-08 03:36:46
问题 If I do a transform to an NSView in Cocoa's app: self.view.layer.transform = CATransform3DMakeRotation(30 * M_PI / 180, 0, 0, 1); I see the square not rotated around the Z-axis, but rotated as if that vector is pointing downward and outward. I need to make it self.view.layer.transform = CATransform3DMakeRotation(30 * M_PI / 180, 1, 1, 1); to make it rotate around the Z-axis, as shown in the picture on this question. However, if I set an NSTimer and then update the transform in the update

How do I update the expansion tooltip size after calling NSTextField setStringValue:?

大兔子大兔子 提交于 2019-12-08 03:08:19
问题 When a view contains an NSTextField with the expansion tooltip enabled and the text doesn't fit, then the user hovers the cursor over the field, OS X shows an expansion tooltip. If you then call setStringValue: to change the text content of the NSTextField , the expansion tooltip's size is not updated. For instance, if the original text was 100 characters long but the new text is only 50 characters long, hovering over the new text will show an expansion tooltip large enough for 100 characters

Purpose of NSRefreshedObjectsKey

南笙酒味 提交于 2019-12-08 02:20:33
问题 In a NSManagedObjectContextObjectsDidChangeNotification notification, I sometimes get the NSRefreshedObjectsKey key. I understand refreshed objects to be a new fetch of the object from the persistent store/cache. What causes the notification to return refreshed objects then? For inserted, updated, deleted, etc it is obvious, but what must I do to an object for it to appear in the NSRefreshedObjectsKey key? E.g. is it that it may have simply been touched in some way (same values written to

Dynamically resize NSWindow based on NSOutlineView height

旧时模样 提交于 2019-12-07 20:53:55
问题 I have read many answers to questions about dynamically resizing NSWindows and nothing has quite worked yet. I have built a 'popover' like window to be displayed form the menu bar, I couldn't use NSPopover because it isn't quite customisable enough in terms of design. My view hierarchy current looks like this: NSWindow Subclass - NSView (clears the titlebar rendering, draws popover arrow) - NSView (contentView) - NSOutlineView (main table of content) - NSView (window footer) What I need is

View and Cell based NSTableView

◇◆丶佛笑我妖孽 提交于 2019-12-07 17:35:11
问题 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

How do I change/modify the displayed title of an NSPopUpButton

旧街凉风 提交于 2019-12-07 12:12:58
问题 I would like an NSPopUpButton to display a different title than the title of the menu item that is selected. Suppose I have an NSPopUpButton that lets the user pick a list of currencies, how can I have the collapsed/closed button show only the currencies abbreviation instead of the menu title of the selected currency (which is the full name of the currency)? I imagine I can override draw in a subclass (of NSPopUpButtonCell ) and draw the entire button myself, but I would prefer a more

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

独自空忆成欢 提交于 2019-12-07 09:30:19
问题 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? 回答1: 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,