- validateVisibleItems
Called on window updates to validate the visible items.
action
The receiver’s action.
target
The receiver’s target.
- validate
This method is called by the receiver’s toolbar during validation.
NO
, NSToolbar will disable theItem
; returning YES
causes theItem
to be enabled.Availability
Technology
- (BOOL)validateToolbarItem:(NSToolbarItem
*)item;
NSToolbar only calls this method for image items.
Note 注意
validate
is called very frequently, so it must be efficient.
If the receiver is the target
for the actions of multiple toolbar items, it’s necessary to determine which toolbar item the
refers to by testing the item
.
-(BOOL)validateToolbarItem:(NSToolbarItem *)toolbarItem
{
BOOL enable = NO;
if ([[toolbarItem itemIdentifier] isEqual:SaveDocToolbarItemIdentifier]) {
// We will return YES (enable the save item)
// only when the document is dirty and needs saving
enable = [self isDocumentEdited];
} else if ([[toolbarItem itemIdentifier] isEqual:NSToolbarPrintItemIdentifier]) {
// always enable print for this window
enable = YES;
}
return enable;
}
- validateVisibleItems
action
target
- validate