How to change dynamically the format of a column in a table view ?
13/09/03 10:44
I want the formatter of a column view to change according to the column view size…
The NSTableView class notifies listeners when column are resized by dispatching the NSTableViewColumnDidResizeNotification. The delegate of the table view is automatically notified: its tableViewColumnDidResize method is called.
The notification object is the NSTableView in which a column was resized:
NSTableView *aTableView = (NSTableView *)[aNotification object] ;
The userInfo dictionary contains this key NSOldWidth with value the column's original width as a NSNumber and the key NSTableColumn with value the resized table's column as a NSTableColumn.
With these informations, you will be able to decide the parameters to use for either the NSCell either its formatter that you will need to assign to the NSTableColumn using [myTableColum setDataCell:myCell] and/or [myCell setFormatter:myFormatter]. Don't forget to force a refresh: [myTableView setNeedsDisplay:YES] at the end of notification's handling code.
The notification object is the NSTableView in which a column was resized:
NSTableView *aTableView = (NSTableView *)[aNotification object] ;
The userInfo dictionary contains this key NSOldWidth with value the column's original width as a NSNumber and the key NSTableColumn with value the resized table's column as a NSTableColumn.
With these informations, you will be able to decide the parameters to use for either the NSCell either its formatter that you will need to assign to the NSTableColumn using [myTableColum setDataCell:myCell] and/or [myCell setFormatter:myFormatter]. Don't forget to force a refresh: [myTableView setNeedsDisplay:YES] at the end of notification's handling code.