nstableviewcell

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

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

context menu based on NSTableViewCell

时光毁灭记忆、已成空白 提交于 2019-12-02 22:39:29
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 the context menu is supposed to look like for any given cell. Theres a delegate for that! - No need to

Change color of NSTableViewCell

匆匆过客 提交于 2019-12-01 15:36:16
How can I change the color of a cell in my NSTableView? Try using a custom NSView for that, or NSTableView 's -setBackgroundColor: method. In your NSTableViewDelegate for the NSTableView , implement this method: - (void)tableView:(NSTableView *)tableView willDisplayCell:(id)cell forTableColumn:(NSTableColumn *)tableColumn row:(NSInteger)row The NSTableView calls this on its delegate before displaying each cell so that you can affect its appearance. Assuming you're using NSTextFieldCells, for the cell that you want to change call: [cell setBackgroundColor:...]; Or, if you want to change the

Change color of NSTableViewCell

孤者浪人 提交于 2019-12-01 14:30:44
问题 How can I change the color of a cell in my NSTableView? 回答1: Try using a custom NSView for that, or NSTableView 's -setBackgroundColor: method. 回答2: In your NSTableViewDelegate for the NSTableView , implement this method: - (void)tableView:(NSTableView *)tableView willDisplayCell:(id)cell forTableColumn:(NSTableColumn *)tableColumn row:(NSInteger)row The NSTableView calls this on its delegate before displaying each cell so that you can affect its appearance. Assuming you're using

Print the NSTableView's row number of the row clicked by the user

余生颓废 提交于 2019-11-29 09:31:35
I have a NSTableView with one column. I would like to print the row number of the row that the user has clicked on. I am not sure where I should start with this. Is there a method for this? You can use the selectedRowIndexes property from the tableView in the tableViewSelectionDidChange method in your NSTableView delegate. In this example, the tableView allows multiple selection. Swift 3 func tableViewSelectionDidChange(_ notification: Notification) { if let myTable = notification.object as? NSTableView { // we create an [Int] array from the index set let selected = myTable.selectedRowIndexes

Print the NSTableView's row number of the row clicked by the user

你。 提交于 2019-11-28 03:02:42
问题 I have a NSTableView with one column. I would like to print the row number of the row that the user has clicked on. I am not sure where I should start with this. Is there a method for this? 回答1: You can use the selectedRowIndexes property from the tableView in the tableViewSelectionDidChange method in your NSTableView delegate. In this example, the tableView allows multiple selection. Swift 3 func tableViewSelectionDidChange(_ notification: Notification) { if let myTable = notification.object