Delaying the opening of a NSPopUpButton

110 views Asked by At

I've encountered the same problem as this one: This one. It has never been answered so far. In two words:

When you place a NSPopUpButtonCell in a NSTableView, the popUp opens before the selection in the tableView has changed.

If the menu of the popUp relies on the selection of a row of the tableView, it will be updated too late.

Solution 1: differ the opening of the popUp with a block which calls [super] a few nanoseconds later. But I don't know which method I must override.

Solution 2: use other bindings that I'm currently using (the popUp contains the NSSet of the entity selected in the table, I'm using a different controller, not the table's one, and I bind its content set to myTable.selection.theSet.

Is there something else I could do? Thanks !

1

There are 1 answers

0
Wil Shipley On

Yes, if you use a view-based tableView, you can bind the popUp through the cellView it’s inside (like the other table objects you bind in this mode), and so it’s completely unambiguous and doesn’t depend on the selection.

In view-based mode, each cell in each row have is assigned an ‘objectValue’ from your original data, so you can bind directly to it, like ‘objectValue.popUpContents’.