Re: NSToolBar Implementation
Re: NSToolBar Implementation
- Subject: Re: NSToolBar Implementation
- From: j o a r <email@hidden>
- Date: Fri, 20 Jul 2001 12:23:54 +0200
On torsdag, juli 19, 2001, at 08:35 , Andreas Monitzer wrote:
Hi Brave Cocoa dev folk! I'm attempting to implement an NSToolbar
which I
began with the provided example. My problem is this: My toolbar
items are
showing up in the toolbar, yet they are all disabled. I'm calling the
setEnabled method for each toolbar item but they are still dimmed out.
I'
m
sure I'm missing some detail. Any ideas, feedback, help, would be much
appreciated.
Try to hook them to some action.
You might also add some toolbaritem validation to your delegate. This is
an example that enables toolbar items only when a condition is satisfied
(in this case selections in an NSOutlineView):
- (BOOL)validateToolbarItem:(NSToolbarItem *)theItem
{
if ([[theItem itemIdentifier] isEqualToString:@"delete"]) {
if ([myOutlineView numberOfSelectedRows] > 0) {
return YES;
} else {
return NO;
}
}
else if ([[theItem itemIdentifier] isEqualToString:@"reveal"]) {
if ([myOutlineView numberOfSelectedRows] == 1) {
return YES;
} else {
return NO;
}
}
else {
NSLog(@"Unknown toolbar item");
return NO;
}
}
Regards,
j o a r