nstableview

NSTableview Change the highlight colour

青春壹個敷衍的年華 提交于 2019-12-03 13:28:16
I am developing a MAC application and included the tableView. Want to change the Colour of selected row to yellow. Set this on your table view: [yourtableview setSelectionHighlightStyle:NSTableViewSelectionHighlightStyleNone]; And implement the following delegate method of NSTableView as: - (void)tableView:(NSTableView *)aTableView willDisplayCell:(id)aCell forTableColumn:(NSTableColumn *)aTableColumn row:(NSInteger)rowIndex { if ([[aTableView selectedRowIndexes] containsIndex:rowIndex]) { [aCell setBackgroundColor: [NSColor yellowColor]]; } else { [aCell setBackgroundColor: [NSColor

How to disable sorting in NSTableVIew?

青春壹個敷衍的年華 提交于 2019-12-03 12:54:01
I have a an NSTableView when ever I click on a specific header column the data in the table get reversed or sort upside down. I have checked NSTableView as well as NSTableColumn but couldn't find any method that disables this. I would be obliged if anyone can help in disabling this sorting on clicking on the header of a particular column. Sorting of the NSTableView is done by its sortDescriptors , see here . An NSTableColumn uses its sortDescriptorPrototype (see here ) to generate the sort descriptor of the NSTableView , depending on how many times you clicked the column header, etc. If you

vertically aligning text in NSTableView row

落爺英雄遲暮 提交于 2019-12-03 11:33:37
问题 I have a small problem with NSTableView. When I am increasing height of a row in table, the text in it is aligned at top of row but I want to align it vertically centered! Can anyone suggest me any way to do it ?? Thanks, Miraaj 回答1: This is a simple code solution that shows a subclass you can use to middle align a TextFieldCell. the header #import <Cocoa/Cocoa.h> @interface MiddleAlignedTextFieldCell : NSTextFieldCell { } @end the code @implementation MiddleAlignedTextFieldCell - (NSRect

reloadData in NSTableView but keep current selection

核能气质少年 提交于 2019-12-03 10:11:36
I have an NSTableView showing the contents of a directory. I watch for FSEvents, and each time I get an event I reload my table view. Unfortunately, the current selection then disappears. Is there a way to avoid that? OzBandit It depends on how you populate your NSTableView. If you have the table view bound to an NSArrayController, which in turn contain the items that your table view is displaying, then the NSArrayController has an option to preserve the selection. You can select it (or not) from within Interface Builder as a property on the NSArrayController. Or you can use the

Coloring rows in View based NSTableview

眉间皱痕 提交于 2019-12-03 10:04:59
I have a view based nstableview. I want to color entire row based on some condtion for which I have used code below - (NSTableRowView *)tableView:(NSTableView *)tableView rowViewForRow:(NSInteger)row { NSTableRowView *view = [[NSTableRowView alloc] initWithFrame:NSMakeRect(1, 1, 100, 50)]; [view setBackgroundColor:[NSColor redColor]]; return view;; } The delegate method is called, but table doesn't seem to be using NSTableRowView returned by delegate method. Main aim here is coloring entire row based on some condition. Whats wrong in above implementation? For anyone else who hits this and

How to increase the height of NSTableHeaderView?

亡梦爱人 提交于 2019-12-03 08:52:14
问题 I need to implement a headerview with specific size and gradient. I have to insert images in certain cells of the headerview .Tried to create the cells for the headerview using the following code,but i was not able to customize the headerview . [[tableColumn headerCell] setImage:[NSImage imageNamed:@"sampleHeader"]]; If I use the overridden subclass of headerview, I was not able to view the images or text in the header cell.Please provide me any pointers to solve this issue. I was able to

Getting duplicate header button cell in NSTableView when using NSPopUpButtonCell

浪尽此生 提交于 2019-12-03 08:43:36
I have a dynamic NSTableView which can add a number of columns depending on the data provided. For each column I have set the header cell to be a NSPopUpButtonCell. (Side-note: I've had to use a custom subclass class for NSTableHeaderView otherwise the menu doesn't pop-up). All works well, apart from a duplicate or extra header button cell on the top right. It mirrors perfectly the previous column selection as shown in screenshots. My question is how do I stop the NSTableView from recycling the previous popup header cell? (By the way I have tried the setCornerView method but that only effects

context menu based on NSTableViewCell

╄→гoц情女王★ 提交于 2019-12-03 07:38:05
问题 i would like to place a context menu onto a NSTableView . this part is done. what i would liek to do is to show different menu entries based on the content of the right clicked cell, and do NOT show the context menu for specific columns. this is: column 0, and 1 no context menu all other cells should have the context menu like this: first entry: "delete " samerow.column1.value second entry: "save " samecolumn.headertext hope the question is clear.. thanks -EDIT- the one on the right is how

Displaying row index in an NSTableView bound to NSArrayController

醉酒当歌 提交于 2019-12-03 07:35:21
I have an NSTableView which is bound to an NSArrayController. I would like to have one of the table columns showing the index of the table row. This is easy enough to do when you implement NSTableDataSource yourself but I can't figure it out with a bound table view. I guess I'm looking here for something like the @count key path which gives me the count of arrangedObjects (that is @index) but this is obviously missing. Two clarifications: The index that is shown in each row is the index of that row and not related at all to the way the data is actually arranged in the model or array controller

Binding view-based NSOutlineView to Core Data

怎甘沉沦 提交于 2019-12-03 03:53:02
问题 I'm trying to implement the new view-based OutlineView as a source list in my Mac app. I can't get values to display, though, so I made a small test app from the Core Data app template, and can't get it working right in there, either. I defined two simple classes in my data model; let's call them "Parent" and "Child". Parent has a single Attribute, "name", and a single relationship, "children". name is an optional string, and children is an optional to-many relationship to Child . Child has