Fix browse dialog parenting
This commit is contained in:
@@ -1,4 +1,9 @@
|
||||
const { app, BrowserWindow, Menu, dialog, ipcMain, fs } = require('electron');
|
||||
|
||||
// Some Linux/remote desktop setups expose a broken GPU context to Electron.
|
||||
// Fall back to software rendering instead of crashing on startup.
|
||||
app.disableHardwareAcceleration();
|
||||
|
||||
function createWindow () {
|
||||
const win = new BrowserWindow({
|
||||
width: 950,
|
||||
@@ -242,22 +247,22 @@ app.on('activate', () => {
|
||||
// Reply to calls from browser button
|
||||
ipcMain.on('browseFolder', (event, args) => {
|
||||
console.log('received a message: '+args);
|
||||
dialog.showOpenDialog({ title: "Select folder",
|
||||
defaultPath : app.getPath('temp'),
|
||||
properties:["openDirectory"]}
|
||||
).then(result => {
|
||||
console.log(result)
|
||||
if (result.canceled || result.filePaths.length === 0) {
|
||||
return;
|
||||
}
|
||||
setImmediate(function() {
|
||||
var focusedWindow = BrowserWindow.getFocusedWindow();
|
||||
focusedWindow.webContents.send('browseFolder',result.filePaths);
|
||||
app.setPath('temp',result.filePaths[0]);
|
||||
});
|
||||
}).catch(err => {
|
||||
console.log(err);
|
||||
})
|
||||
const senderWindow = BrowserWindow.fromWebContents(event.sender);
|
||||
dialog.showOpenDialog(senderWindow, { title: "Select folder",
|
||||
defaultPath : app.getPath('temp'),
|
||||
properties:["openDirectory"]}
|
||||
).then(result => {
|
||||
console.log(result)
|
||||
if (result.canceled || result.filePaths.length === 0) {
|
||||
return;
|
||||
}
|
||||
setImmediate(function() {
|
||||
senderWindow.webContents.send('browseFolder',result.filePaths);
|
||||
app.setPath('temp',result.filePaths[0]);
|
||||
});
|
||||
}).catch(err => {
|
||||
console.log(err);
|
||||
})
|
||||
});
|
||||
|
||||
//ipcMain.on('browseFolder-send', (event, args) => {
|
||||
|
||||
Reference in New Issue
Block a user