 |
 |
Clicked column action in NSTableView
|
 |
|
 |
|
Mac Enthusiast
Join Date: Sep 2000
Location: Vermont, USA
Status:
Offline
|
|
I have been trying to get this to work for some time. My quest is simple, have a method called when a column header is clicked in my NSTableView. I am new at this, so that is probably why I haven't figured it out. I am programming in Cocoa Java. The following piece of code gets called in a method when my app is setting up the NSTableView:
NSArray array = myTable.tableColumns(); //get an array of table columns
for (int i=0; i< array.count();i++) {
NSTableColumn aColumn = (NSTableColumn)array.objectAtIndex(i);
if (aColumn.identifier().equals("aIdentifier")) { //find the one I want
aColumn.headerCell().setAction(new NSSelector("callThisMethod", new Class[] { MyApp.class })); //set the action
}
}
This compiles fine and is getting called, but when I click the table column with identifier "aIdentifier" the "callThisMethod" isn't called. Anyone have any suggestions?
Thanks in advance.
|
|
|
| |
|
|
|
 |
|
 |
|
Grizzled Veteran
Join Date: Feb 2001
Location: Germany
Status:
Offline
|
|
no idea about cocoa java, but with objective-c, the deal is that it only gets called when you allow reordering of your columns in ib.
|
|
|
| |
|
|
|
 |
|
 |
|
Mac Enthusiast
Join Date: Sep 2000
Location: Vermont, USA
Status:
Offline
|
|
I have allowed column reordering in IB, but I thought that was to actually allow the columns to be dragged by the user to be re-ordered. I just want it so that when a user clicks a column header, a method (of my choosing) gets called.
|
|
|
| |
|
|
|
 |
|
 |
|
Senior User
Join Date: Mar 2000
Location: Ithaca, NY
Status:
Offline
|
|
I've had problems with this when column selection is turned on, so you might try turning that checkbox off in IB if it's not already. The next thing I'd make sure is that you have both the data source and the delegate outlets of the table view pointing to your controller object, and put some NSLog()s in some other methods to make sure all the connections are set up correctly.
|
|
|
| |
|
|
|
 |
|
 |
|
Mac Enthusiast
Join Date: Sep 2000
Location: Vermont, USA
Status:
Offline
|
|
I tried unchecking the checkbox for allows re-ordering in IB, still no luck. I also double checked my connections and the delegate and data source are both hooked up properly. Does the code above look like it should work? It compiles and gets called when the program launches, but doesn't seem like it is doing anything.
|
|
|
| |
|
|
|
 |
 |
|
 |
|
|
|
|
|

|
|
 |
Forum Rules
|
 |
 |
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
|
HTML code is Off
|
|
|
|
|
|
 |
 |
 |
 |
|
 |