0

I'm making a Finder plugin but when I ask for the selected files the method only give me 10 items at most.

[FIFinderSyncController defaultController].selectedItemURLs

UPDATE: I got it half solved... I'm using ScriptingBridge to access Finder and get the selected items of the frontmost window. (sandbox requires: com.apple.security.temporary-exception.apple-events). The weird thing is that the context menu appears after a short time even if your application menu is 'cooking' its items to show. Your items appear after you've done creating them anyway. The only problem is that the ScriptingBridge will not execute if there is a context menu or modal object inside Finder window. It finishes executing only if you dismiss the menu. I can only get selected items inside the menuForMenuKind using FIFinderSyncController, but I can get all items after I trigger a menu action using ScriptingBridge. It is important for my application to know what items I have selected before showing the menu with the corresponding actions, but I'll have to be happy with this solution for now.

  • How many items are you expecting to have returned? – Eric Oct 27 '15 at 07:33
  • I expect to get the number of items I have selected in Finder. It works, but if I select more than 10 items it just says I've selected 10, not more than that. Seems to be some kind o limit from Apple. I don't know. – Carlos César Neves Enumo Oct 27 '15 at 11:56
  • I'm using `selectedItemURLs` and can gen a selection of even 1000 items. Please show your code, you must be doing something else wrong. – Mugen Nov 10 '15 at 06:59
  • @Mugen well... thats good to know... if it is not a bug i will take a second look at my code... unfortunately i cannot share it because it is proprietary – Carlos César Neves Enumo Nov 10 '15 at 11:12
  • @Mugen it happens that even Dropbox extension can only move 10 files at once using its context menu. I think you misunderstood the problem, but if you really have a workaround for this, it would be great if you teach me! – Carlos César Neves Enumo Nov 11 '15 at 01:26
  • Posted as answer, for the code snaps and screenshot – Mugen Nov 11 '15 at 06:39
  • @Mugen what component is that? It looks like a file picker (NSOpenPanel), not actually a Finder window. Maybe that component is not limited. – Carlos César Neves Enumo Nov 11 '15 at 11:09
  • It's a simple Finder window, can't screenshot a wider version since I too have proprietary problems – Mugen Nov 11 '15 at 11:21

1 Answers1

0

For the following code:

- (NSMenu *)menuForMenuKind:(FIMenuKind)whichMenu
{
    NSArray *selectedPaths = [self getSelectedItems];
    // ...
    return ...
}

- (NSArray *)getSelectedItems
{
    NSMutableArray *selectedItems = [[NSMutableArray alloc] init];
    for (NSURL *selectedItemURL in [[FIFinderSyncController defaultController] selectedItemURLs]) {
        [selectedItems addObject:selectedItemURL.path];
        NSLog(@"FinderSync selected item at path '%@'", selectedItemURL.path);
    }
    return selectedItems;
}

And for the following directory:

11 Files

I'm getting the following output when selecting all files in the directory and opening the context menu:

11/11/15 7:52:24.432 AM MyFinderSync[28375]: FinderSync selected item at path '/Users/Mugen/Workspace/11 Files/1.txt'
11/11/15 7:52:24.432 AM MyFinderSync[28375]: FinderSync selected item at path '/Users/Mugen/Workspace/11 Files/2.txt'
11/11/15 7:52:24.432 AM MyFinderSync[28375]: FinderSync selected item at path '/Users/Mugen/Workspace/11 Files/3.txt'
11/11/15 7:52:24.432 AM MyFinderSync[28375]: FinderSync selected item at path '/Users/Mugen/Workspace/11 Files/4.txt'
11/11/15 7:52:24.433 AM MyFinderSync[28375]: FinderSync selected item at path '/Users/Mugen/Workspace/11 Files/5.txt'
11/11/15 7:52:24.433 AM MyFinderSync[28375]: FinderSync selected item at path '/Users/Mugen/Workspace/11 Files/6.txt'
11/11/15 7:52:24.433 AM MyFinderSync[28375]: FinderSync selected item at path '/Users/Mugen/Workspace/11 Files/7.txt'
11/11/15 7:52:24.433 AM MyFinderSync[28375]: FinderSync selected item at path '/Users/Mugen/Workspace/11 Files/8.txt'
11/11/15 7:52:24.433 AM MyFinderSync[28375]: FinderSync selected item at path '/Users/Mugen/Workspace/11 Files/9.txt'
11/11/15 7:52:24.434 AM MyFinderSync[28375]: FinderSync selected item at path '/Users/Mugen/Workspace/11 Files/10.txt'
11/11/15 7:52:24.434 AM MyFinderSync[28375]: FinderSync selected item at path '/Users/Mugen/Workspace/11 Files/11.txt'
Mugen
  • 8,301
  • 10
  • 62
  • 140