Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

like image 761
famalgosner Avatar asked Nov 09 '22 02:11

famalgosner


1 Answers

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]);
    }
}
like image 55
spring Avatar answered Dec 11 '22 03:12

spring