简体   繁体   中英

How do I get the representedObject from an NSTextView in an NSCollectionViewItem

Similar to this question ( Get the representedObject values of NSCollectionViewItem NSButton click ) that asks how to get the representedObject of an action invoked from an NSButton, how do I get the representedObject of an action invoked from an NSTextView in an NSCollectionViewItem? I have a method in the NSTextView's delegate that is called when the user presses "tab" in the NSTextView. However, I do not know how to figure out which view called the action, as there is no "representedObject" outlet for an NSTextView like there is in the cell of an NSButton.

well you can do this a bunch of different ways, you could ask the text view for its superview... which could be the item... depending on your layout. You could set up a dictionary of views and items, you could subclass the text view to have a represented object, or you could use bindings...

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM