nstableview

which method is called when selecting a cell in the NSTableView in Cocoa OS X?

跟風遠走 提交于 2019-12-01 01:29:55
问题 I have a NSTableView , i want to get the value present in the cell. I am having only one column so , i just need the row number i can use this [tableView selectedRow]- but where do i put this i want to put this in a method that gets called on selection of any of the rows. -(void)tableViewSelectionDidChange:(NSNotification *)notification{ NSLog(@"%d",[tableViewController selectedRow]); } The above method also does not work i am getting the error -[NSScrollView selectedRow]: unrecognized

Add/remove rows to/from NSTableView in Objective-C

僤鯓⒐⒋嵵緔 提交于 2019-11-30 20:08:05
I'm making a simple Todo application in Cocoa. I have added a class (and an NSObject to the XIB) MATodoController: MATodoController.h #import <Cocoa/Cocoa.h> @interface MATodoController : NSObject { IBOutlet NSTableView *table; } - (IBAction)addItem:(id)sender; - (IBAction)removeItem:(id)sender; @end MATodoController.m #import "MATodoController.h" @implementation MATodoController - (void)addItem:(id)sender { } - (void)removeItem:(id)sender { } @end I have an outlet 'table' to an NSTableView and two actions 'addItem' and 'removeItem' called by button clicks. Is there a way (ofcourse there is a

How to update row heights of NSTableView with usesAutomaticRowHeights = true after column resize?

我是研究僧i 提交于 2019-11-30 19:47:16
问题 Since macOS 10.13 we can use NSTableView with automatic row heights, thanks to the new property usesAutomaticRowHeights and of course auto layout. This works quite nicely. But when the user resizes a column, the calculated heights are no longer correct, and gaps appear in the tableview cells. Is there a proven way to update the row heights after column resize in this scenario? I already tried methods like updateConstraintsForSubtreeIfNeeded() , updateConstraints() , setNeedsDisplay() ,

NSTableView & NSOutlineView editing on tab key

陌路散爱 提交于 2019-11-30 14:17:30
My app has an NSOutlineView and an NSTableView , and I'm having the same problem with both. With a row in either selected, pressing the tab key puts the first column into edit mode instead of making the next key view first responder. To get to the next key view, you need to tab through all of the columns. Also, shift-tabbing into either view results in the last column going into edit mode, necessitating more shift-tabs to get into its previous key view. In case it matters, I'm using the autocalculated key view loop, not my own, with my NSWindow set to autorecalculatesKeyViewLoop = YES . I

Customize right click highlight on view-based NSTableView

爷,独闯天下 提交于 2019-11-30 14:04:16
I have a view-based NSTableView with a custom NSTableCellView and a custom NSTableRowView. I customized both of those classes because I want to change the appearance of each row. By implementing the [NSTableRowView draw...] methods I can change the background, the selection, the separator and the drag destination highlight. My question is: how can I change the highlight that appears when the row is right clicked and a menu appears? For example, this is the norm: And I want to change the square highlight to a round one, like this: I'd imagine this would be done in NSTableRowView by calling a

Change NSTableView alternate row colors

断了今生、忘了曾经 提交于 2019-11-30 12:40:39
问题 I'm using the "Alternating Rows" option in Interface Builder to get alternating row colors on an NSTableView. Is there any way to change the colors of the alternating rows? 回答1: If you want to use an undocumented way, make a NSColor category and override _blueAlternatingRowColor like this: @implementation NSColor (ColorChangingFun) +(NSColor*)_blueAlternatingRowColor { return [NSColor redColor]; } @end or to change both colors, override controlAlternatingRowBackgroundColors to return an array

How to Expand NSTableCellView Width When Resizing Column in NSTableView

强颜欢笑 提交于 2019-11-30 12:34:48
I am trying to display a path in my table view. Both columns of the table view on the left side are the same for testing/demonstration purposes. Notice how the leftmost path is truncated: When I expand the column, the (truncated) table view cell doesn't expand with the column: My question is how would I go about resizing the cell when I resize the table view column? Found a solution, what you want to do is add a few constraints Step 1: go to the table cell view for said column Step 2: Change these constraints Step 3: Change these constraints aswell Step 4: run your app and look at your nice

NSTextField in NSTableCellView

馋奶兔 提交于 2019-11-30 10:23:44
I have a view based NSTableView with a custom NSTableCellView. This custom NSTableCellView has several labels (NSTextField). The whole UI of the NSTableCellView is built in IB. The NSTableCellView can be in a normal state and in a selected state. In the normal state all text labels should be black, in the selected state they should be white. How can I manage this? Probably the easiest way to accomplish this would be to subclass NSTextField and to override the drawRect: method in your subclass. There you can determine whether the NSTableCellView instance containing your NSTextField instances is

View-based NSOutlineView without NIB?

冷暖自知 提交于 2019-11-30 09:38:14
NSOutlineView is a subclass of NSTableView . And currently, NSTableView supports two implementations. Cell-based. View-based. To make OSX 10.8 Finder style side bar ( with automatic gray Icon styling ), need to use view-based table view with source-list highlight style. With NIBs, this is typical job. Nothing hard. (see SidebarDemo ) But I want to avoid any NIBs or Interface Builder. I want make the side bar purely programmatically. In this case, I have big problem. AFAIK, there's no way to supply prototype view for specific cell. When I open .xib file, I see <tableColumn> is containing

Get button's row in view based table

这一生的挚爱 提交于 2019-11-30 08:18:31
问题 How do you get the row for a button in a view based table when you click the button? The row is not selected when the button is clicked, but I found that if you log sender.superview.superview in the button's action method, I get: NSTableRowView: 0x1001b3a90 - row: 2. So, the row is there in the log, but I don't know how to get at it programmatically. I have the button's action method in a subclass of NSTableCellView. 回答1: -[NSTableView rowForView:] says this in its documentation: This is