branchseer / DeskGap

A cross-platform desktop app framework based on Node.js and the system webview
https://deskgap.com/
MIT License
1.83k stars 75 forks source link

Window doesn't go on top on MacOS #36

Closed sheerun closed 4 years ago

sheerun commented 4 years ago

Hello!

I'm noticing that when I run DeskGap on MacOS, the created window stays below terminal.. Is there a way to force newly opened window to be on top?

mdings commented 4 years ago

I have the same issue. Showing the window doesn't necessarily mean it is shown as the active one on top of any others. This seems to be a bug because the Deskgap window actually does move but always one level behind the topmost one. So if that window covers your window you will never see it.

ghost commented 4 years ago

Here is my trick 😄

    app.once('ready', () => {
        mainWindow = new BrowserWindow({
            title: 'My App',
            titleBarStyle: 'default',
            resizable: false,
            show: false,
            width: 500, height: 300,
            center: true,
        }).once('ready-to-show', () => {                                       
            mainWindow.show();
            exec('osascript -e \'tell application "My App" to activate\'');           
          }            
        });

        mainWindow.loadFile('index.html');

        mainWindow.on('closed', () => {
            mainWindow = null;
            app.quit();
        });        
    });