FROM : Jonathan Guy
DATE : Wed Jul 05 14:43:41 2006
Thanks guys that helped me out
just tackling drag n drop with NSTreeController now.
On Friday, June 30, 2006, at 06:17PM, Matt Neuburg <<email_removed>> wrote:
>On Fri, 30 Jun 2006 15:19:39 +0100, Jonathan Guy <<email_removed>> said:
>
>> This would seem an easy thing to do but can't figure it out. I want to bind
>> the "Enabled" part of a button to the selection of a tree controller BUT I
>> only want the button to be enable when there is a single item selected in the
>> outline view (NOT a zero or multiple selection).
>
>Another solution (besides the value transformer approach from my earlier
>message) would be a controller subclass. In the case of NSArrayController,
>we could bind the button's Enabled to an ivar (because that's an
>observable). The ivar is set by code that takes advantage of the fact that
>selectedObjects, too, is an observable:
>
>@implementation MyNSArrayController
>
>- (void) awakeFromNib {
> [self addObserver:self forKeyPath:@"selectedObjects"
> options:0 context:nil];
>}
>
>- (void)observeValueForKeyPath:(NSString *)keyPath
> ofObject:(id)object change:(NSDictionary *)change
> context:(void *)context {
> [self setValue:
> [NSNumber numberWithBool:
> [[self selectedObjects] count] == 1]
> forKey: @"selectionIsOne"];
>}
>
>@end
>
>So we bind the button's Enabled to the controller's "selectionIsOne" and
>presto, we're there.
>
>m.
>
>--
>matt neuburg, phd = <email_removed>, <http://www.tidbits.com/matt/>
>A fool + a tool + an autorelease pool = cool!
>AppleScript: the Definitive Guide - Second Edition!
><http://www.amazon.com/gp/product/0596102119>
>
>
>
>
>
DATE : Wed Jul 05 14:43:41 2006
Thanks guys that helped me out
just tackling drag n drop with NSTreeController now.
On Friday, June 30, 2006, at 06:17PM, Matt Neuburg <<email_removed>> wrote:
>On Fri, 30 Jun 2006 15:19:39 +0100, Jonathan Guy <<email_removed>> said:
>
>> This would seem an easy thing to do but can't figure it out. I want to bind
>> the "Enabled" part of a button to the selection of a tree controller BUT I
>> only want the button to be enable when there is a single item selected in the
>> outline view (NOT a zero or multiple selection).
>
>Another solution (besides the value transformer approach from my earlier
>message) would be a controller subclass. In the case of NSArrayController,
>we could bind the button's Enabled to an ivar (because that's an
>observable). The ivar is set by code that takes advantage of the fact that
>selectedObjects, too, is an observable:
>
>@implementation MyNSArrayController
>
>- (void) awakeFromNib {
> [self addObserver:self forKeyPath:@"selectedObjects"
> options:0 context:nil];
>}
>
>- (void)observeValueForKeyPath:(NSString *)keyPath
> ofObject:(id)object change:(NSDictionary *)change
> context:(void *)context {
> [self setValue:
> [NSNumber numberWithBool:
> [[self selectedObjects] count] == 1]
> forKey: @"selectionIsOne"];
>}
>
>@end
>
>So we bind the button's Enabled to the controller's "selectionIsOne" and
>presto, we're there.
>
>m.
>
>--
>matt neuburg, phd = <email_removed>, <http://www.tidbits.com/matt/>
>A fool + a tool + an autorelease pool = cool!
>AppleScript: the Definitive Guide - Second Edition!
><http://www.amazon.com/gp/product/0596102119>
>
>
>
>
>
| Related mails | Author | Date |
|---|---|---|
| Jonathan Guy | Jun 30, 16:19 | |
| George Orthwein | Jun 30, 17:27 | |
| Scott Anguish | Jun 30, 18:00 | |
| Matt Neuburg | Jun 30, 18:51 | |
| Matt Neuburg | Jun 30, 19:13 | |
| Jonathan Guy | Jul 5, 14:43 |






Cocoa mail archive

