зеркало из https://github.com/mozilla/pjs.git
New category on NSResponder to find the responder for a given action, and find an item of a particular class in the responder chain.
Add method on NSMenu category to enable or disable all items (potentially recursing into submenus).
This commit is contained in:
Родитель
bb7b5fd5bb
Коммит
c6aec66d04
|
@ -46,6 +46,10 @@
|
|||
// turning on the one with the given unmasked tag value.
|
||||
- (void)checkItemWithTag:(int)unmaskedTag inGroupWithMask:(int)tagMask;
|
||||
|
||||
// enable or disable all items in the menu including and after inFirstItem,
|
||||
// optionally recursing into submenus.
|
||||
- (void)setAllItemsEnabled:(BOOL)inEnable startingWithItemAtIndex:(int)inFirstItem includingSubmenus:(BOOL)includeSubmenus;
|
||||
|
||||
@end
|
||||
|
||||
|
||||
|
|
|
@ -67,6 +67,22 @@
|
|||
}
|
||||
}
|
||||
|
||||
- (void)setAllItemsEnabled:(BOOL)inEnable startingWithItemAtIndex:(int)inFirstItem includingSubmenus:(BOOL)includeSubmenus
|
||||
{
|
||||
NSArray* menuItems = [self itemArray];
|
||||
|
||||
int i;
|
||||
for (i = inFirstItem; i < [menuItems count]; i ++)
|
||||
{
|
||||
id<NSMenuItem> curItem = [self itemAtIndex:i];
|
||||
[curItem setEnabled:inEnable];
|
||||
if (includeSubmenus && [curItem hasSubmenu])
|
||||
{
|
||||
[[curItem submenu] setAllItemsEnabled:inEnable startingWithItemAtIndex:0 includingSubmenus:includeSubmenus];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче