allow new menu method to use an index set instead of range
This commit is contained in:
parent
420115e322
commit
ca6f1934b3
|
@ -26,6 +26,6 @@
|
||||||
|
|
||||||
@interface NSMenu (NSMenuAdditions)
|
@interface NSMenu (NSMenuAdditions)
|
||||||
|
|
||||||
- (void) moveItemsToEndFromMenu: (NSMenu *) oldMenu inRange: (NSRange) range;
|
- (void) appendItemsFromMenu: (NSMenu *) menu atIndexes: (NSIndexSet *) indexes;
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|
|
@ -26,15 +26,17 @@
|
||||||
|
|
||||||
@implementation NSMenu (NSMenuAdditions)
|
@implementation NSMenu (NSMenuAdditions)
|
||||||
|
|
||||||
- (void) moveItemsToEndFromMenu: (NSMenu *) oldMenu inRange: (NSRange) range
|
- (void) appendItemsFromMenu: (NSMenu *) menu atIndexes: (NSIndexSet *) indexes
|
||||||
{
|
{
|
||||||
|
int bottom = [self numberOfItems];
|
||||||
|
|
||||||
NSMenuItem * item;
|
NSMenuItem * item;
|
||||||
int i;
|
unsigned int i;
|
||||||
for (i=0; i<range.length; i++)
|
for (i = [indexes lastIndex]; i != NSNotFound; i = [indexes indexLessThanIndex: i])
|
||||||
{
|
{
|
||||||
item = [[oldMenu itemAtIndex: range.location] retain];
|
item = [[menu itemAtIndex:i] retain];
|
||||||
[oldMenu removeItem: item];
|
[menu removeItem: item];
|
||||||
[self addItem: item];
|
[self insertItem: item atIndex: bottom];
|
||||||
[item release];
|
[item release];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -318,7 +318,7 @@
|
||||||
|
|
||||||
//add file menu items to action menu
|
//add file menu items to action menu
|
||||||
NSRange range = NSMakeRange(0, [fileMenu numberOfItems]);
|
NSRange range = NSMakeRange(0, [fileMenu numberOfItems]);
|
||||||
[fActionMenu moveItemsToEndFromMenu: fileMenu inRange: range];
|
[fActionMenu appendItemsFromMenu: fileMenu atIndexes: [NSIndexSet indexSetWithIndexesInRange: range]];
|
||||||
|
|
||||||
//place menu below button
|
//place menu below button
|
||||||
NSRect rect = [self actionRectForRow: row];
|
NSRect rect = [self actionRectForRow: row];
|
||||||
|
@ -334,7 +334,7 @@
|
||||||
|
|
||||||
//move file menu items back to the torrent's file menu
|
//move file menu items back to the torrent's file menu
|
||||||
range.location = [fActionMenu numberOfItems] - range.length;
|
range.location = [fActionMenu numberOfItems] - range.length;
|
||||||
[fileMenu moveItemsToEndFromMenu: fActionMenu inRange: range];
|
[fileMenu appendItemsFromMenu: fActionMenu atIndexes: [NSIndexSet indexSetWithIndexesInRange: range]];
|
||||||
|
|
||||||
[fMenuTorrent release];
|
[fMenuTorrent release];
|
||||||
fMenuTorrent = nil;
|
fMenuTorrent = nil;
|
||||||
|
|
Loading…
Reference in New Issue