Add removeAllItems method

This commit is contained in:
Gregory Casamento 2023-08-29 16:56:59 +00:00
parent 983bc7d361
commit 7cdf35f73f
3 changed files with 24 additions and 0 deletions

View file

@ -4,6 +4,12 @@
-decodeObjectForXib:forClassName:withID: to decode toolTip using
alternative format described in the issue.
2023-08-29 Gregory Casamento <greg.casamento@gmail.com>
* Headers/AppKit/NSMenu.h (-removeAllItems): Add method declaration.
* Source/NSMenu.m (-removeAllItems): Add implementation to remove
all menu items in the reciever.
2023-08-13 Fred Kiefer <FredKiefer@gmx.de>
* Source/NSSwitch.m (-drawRect:): Correct drawing as suggested by

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;