javascriptneutralinojs

How to show/hide the main app window in NeutralinoJS?


I have a tray app that needs to start up without a main app window (or with it hidden). If the users selects a specific tray menu item, I want to open a window to allow them to perform a task and then close or hide it again.

Is it possible to configure the app to start with the window hidden in neutrino.config.json, or is there another way to do this? Also, how do I show/hide a window programatically?

Thanks.


Solution

  • You can use "modes": { "window": { "hidden": true }} in neutralino.config.json. You can also call Neutralino.window.show() in your Javascript. I'm not sure how a tray menu item works, but in the neutralino.js file, Neutralino.window.show() is implemented

    t.show = function() {
        return r.request({
            url: "window.show",
            type: r.RequestType.GET,
            isNativeMethod: !0
        })
    }
    

    which sends a GET to your Neutralino app's server. If you can find the port when/after you start up your Neutralino app, you should be able to send it the same thing from your tray menu item.