NSPredicateEditorRowTemplate and dynamic templateViews
NSPredicateEditorRowTemplate and dynamic templateViews
- Subject: NSPredicateEditorRowTemplate and dynamic templateViews
- From: Dave DeLong <email@hidden>
- Date: Fri, 12 Mar 2010 14:47:06 -0700
Hi everyone,
I'm trying to build a custom predicate editor row template that lets me do predicates like "in the last 30 days" or "since {aDate}". For the simple date comparison, I'm returning an NSDatePicker as the third view in my templateViews.
My problem is that I only want to return the NSDatePicker if the operator is =, !=, <, <=, >, or >=. If the operator is "in the last" (a custom operator), I want to return 4 template views: the first two being the standard keypath + operator views, but the last two being an NSTextField (with NSNumberFormatter attached) and an NSPopUpButton (with the units: days, weeks, months, etc).
I thought that I'd just be able to check which item was selected in the operators popup and return the appropriate views based on the current operator.
Unfortunately, it seems like the predicateEditor invokes templateViews *before* the operator actually changes. In other words, if the operator is =, and I switch it to >=, then when templateViews is invoked, the operators popup still says =, and won't say >= until it's changed again.
So my question is this: how can I dynamically modify my row's templateViews to accurately reflect the current operator? I *could* post a notification from the RowTemplate that the editor needs redrawing, and then have my controller capture that notification and invoke reloadPredicate on my predicate editor, but that seems like a really hackish work-around.
Any recommendations?
(for an example of what I'm describing, try creating a new smart playlist in iTunes and fiddling around with the operators corresponding to the Date Added attribute)
Thanks!
Dave
Attachment:
smime.p7s
Description: S/MIME cryptographic signature
_______________________________________________
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