Add implementation of removeAllItems

This commit is contained in:
Gregory Casamento 2023-09-01 17:12:05 +00:00
parent 3f35da7860
commit 3575f0af77
2 changed files with 18 additions and 0 deletions

View file

@ -633,6 +633,12 @@ APPKIT_EXPORT_CLASS
*/
- (void) removeItemAtIndex: (NSInteger)index;
#if OS_API_VERSION(MAC_OS_X_VERSION_10_6, GS_API_LATEST)
/** Removes all items
*/
- (void) removeAllItems;
#endif
/** Sets if a menu does autoenable.
*/
- (void) setAutoenablesItems: (BOOL)flag;

View file

@ -849,6 +849,18 @@ static BOOL menuBarVisible = YES;
[self menuChanged];
}
- (void) removeAllItems
{
NSUInteger count = [_items count];
NSUInteger index = 0;
for (index = 0; index < count; index++)
{
// always remove item 0 since the index will chane with each removal..
[self removeItemAtIndex: 0];
}
}
- (void) itemChanged: (id <NSMenuItem>)anObject
{
NSNotification *changed;