famalgosner
famalgosner

Reputation: 95

Show files in Electron Dialog/showOpenDialog when open directory

Is there a possibility to display files in the showOpenDialog even when the property is set to 'openDirectory'? Of course, files should not be selectable, but maybe shown greyed out. So the user knows that he selects the right directory. On OSX everything is fine, but on Windows the files are not shown at all.

I already tried to display hiddenFiles and added filters. But nothing worked :-/

Thanks in advance! Cheers

Upvotes: 5

Views: 2780

Answers (1)

spring
spring

Reputation: 18487

It works for me (on OSX) – I see greyed out files – perhaps you are calling it wrong?

function showDirectorySelector() {
    var options = {
        title: "Select Directory",
        properties: ['openDirectory'],
    }
    dialog.showOpenDialog(mainWindow, options, directorySelectorCallback);
}

function directorySelectorCallback(filenames) {
    if (filenames && filenames.length > 0) {
       mainWindow.webContents.send('project-directory-selected', filenames[0]);
    }
}

Upvotes: 1

Related Questions