Re: NSPredicateEditorRowTemplate: Custom templateView state
Re: NSPredicateEditorRowTemplate: Custom templateView state
- Subject: Re: NSPredicateEditorRowTemplate: Custom templateView state
- From: Peter Ammon <email@hidden>
- Date: Wed, 4 Jun 2008 13:27:39 -0700
On Jun 3, 2008, at 12:05 PM, Mario Fischer wrote:
Hi -
- I use the NSPredicateEditor with a custom
NSPredicateEditorRowTemplate
- This custom component should implement something like this:
[Filesize] - [is smaller/greater than] - [Textfield] - [KB/MB/GB]
By overriding templateViews I'm able to add an additional
NSPopupButton to the existing ones:
- (NSArray *)templateViews
{
NSArray* myviews = [super templateViews];
NSPopUpButton* myButton = [[NSPopUpButton alloc] init];
[myButton addItemsWithTitles:[NSArray arrayWithObjects:@"KB",
@"MB", @"GB", nil]];
return [NSArray arrayWithObjects: [myviews objectAtIndex:0],
[myviews objectAtIndex:1],[myviews objectAtIndex:2], myButton, nil];
}
But in predicateWithSubpredicates I can't find out, which of the
entries the user selected:
- (NSPredicate *)predicateWithSubpredicates:(NSArray *)subpredicates
{
[[[self templateViews] objectAtIndex:1] titleOfSelectedItem]; //
works
[[[self templateViews] objectAtIndex:3] titleOfSelectedItem]; // is
always the first entry, regardless of the user selection..
...
}
What am I missing here / doing wrong?
Hi Mario,
Your code is creating a new instance of NSPopUpButton with every call
to templateViews. When you call templateViews again to check the
value of the last popup, you get a different popup every time.
It looks like maybe you just accidentally declared myButton as a local
variable instead of an instance variable.
-Peter
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden