table view, popup, bindings: more grief...
table view, popup, bindings: more grief...
- Subject: table view, popup, bindings: more grief...
- From: Ondra Cada <email@hidden>
- Date: Fri, 31 Mar 2006 21:11:56 +0200
Hello all,
just a few more details:
- a standalone pop-up bound the very same way to selection works
well; alas, that's not a solution for my project;
- the culprit does not seem to be the popup itself, but rather the
bindings: for some godforsaken reason the popup gets depopulated (by
removeAllItems) *as soon as it is opened* (not, as one would presume,
closed!), and the *next* item in the controller is asked for its
popupValues;
- all the visible popups actually get repopulated pretty often
without a real need (e.g., when another app -- like the gdb -- goes
foreground: that does not quite help debuggin' :));
- thus, it does not seem the popup "keeps old" list; instead, it
seems to be too eager to get a new one.
Sadly, not even with my own subclass of NSPopupCell I've been able to
find a pattern to implement this seemingly extremely simple
behaviour :( Am I overlooking something quite obvious here?
=== original message with the problem description ===
I've bumped into another problem with a table view containing a popup
column bound to model: As soon as the popup values differ for
different model object instances, all hell breaks loose.
A test model code may look like this:
@interface Model : NSObject {
int number; // controls the range and interpretation for tag
int tag; // for positive numbers, 0-1, for negative numbers,
0-3, for zero zero only
}
@end
@implementation Model // there's a bit more in real code--see the
archive for complete source, this is the gist
-(NSArray*)popupValues {
if (number==0) return [NSArray arrayWithObject:@"none"]; //
nothing for zero
if (number>0) return [NSArray arrayWithObjects:@"+",@"+
+",nil]; // 0-1 all right for positive
return [NSArray
arrayWithObjects:@"-",@"--",@"---",@"----",nil]; // 0-3 all right for
negative
}
@end
There is an NSArrayController which keeps an array of these Models,
and a table with two columns. First is a plain editor bound to
"number"; second is a popup whose "contentValues" are bound to
"popupValues" and "selectedIndex" bound to "tag".
One would say it's simple enough to be bound to (sorry for the
pun ;)) work, but it seems the popup cells do not sync with proper
model object, getting the "contentValues" instead from seemingly
random one: at first, the table displays all right, but as soon as it
contains objects with zero, positive, and negative numbers, and you
try to actually use the popups, ugly things occur (wrong popups
shown, values don't change when edited, "3" instead of "----"
displayed for negative "numbers", etc).
Can anybody please advice how to solve the problem? TIA!
A complete project to test it, along with slightly improved model
implementation (change of number should trigger change of popup, also
change of number zeroes tag) is at http://www.ocs.cz/apps/
TablePopupProblem.zip.
---
Ondra Čada
OCSoftware: email@hidden http://www.ocs.cz
private email@hidden http://www.ocs.cz/oc
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden