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:
smfr%smfr.org 2005-03-25 06:36:29 +00:00
Родитель bb7b5fd5bb
Коммит c6aec66d04
4 изменённых файлов: 20 добавлений и 0 удалений

Просмотреть файл

@ -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

Просмотреть файл

Просмотреть файл