neutralinojs / neutralinojs

Portable and lightweight cross-platform desktop application development framework

Home Page:https://neutralino.js.org

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

windowClose event not triggered

ziyouchutuwenwu opened this issue Β· comments

Describe the bug
windowClose event not triggered

To Reproduce
Steps to reproduce the behavior:

  1. install neu cli
npm install -g @neutralinojs/neu
  1. create project
neu create demo --template neutralinojs/neutralinojs-zero
  1. code
    index.html
<!DOCTYPE html>
<html>
  <head>
    <meta charset="UTF-8" />
    <title>Hello Neutralinojs</title>
    <style>
      body {
        background-color: white;
      }
    </style>
  </head>
  <body>
    It works πŸš€
    <script src="neutralino.js"></script>
    <script>
      Neutralino.init();
      Neutralino.events.on("ready", () => {
        Neutralino.os.showMessageBox("ready", "on ready");
      });
      Neutralino.events.on("windowClose", () => {
        Neutralino.os.showMessageBox("close", "will close");
      });
    </script>
  </body>
</html>

neutralino.config.json

{
  "applicationId": "js.neutralino.zero",
  "version": "1.0.0",
  "defaultMode": "window",
  "documentRoot": "/www/",
  "url": "/",
  "enableServer": true,
  "enableNativeAPI": true,
  "nativeAllowList": [
    "app.*",
    "os.*"
  ],
  "modes": {
    "window": {
      "title": "demo",
      "width": 800,
      "height": 500,
      "minWidth": 400,
      "minHeight": 200,
      "icon": "/www/icon.png"
    }
  },
  "cli": {
    "binaryName": "demo",
    "resourcesPath": "/www/",
    "extensionsPath": "/extensions/",
    "clientLibrary": "/www/neutralino.js",
    "binaryVersion": "5.1.0",
    "clientVersion": "5.1.0"
  }
}

Expected behavior
both ready and windowClose event will be called

Screenshots/Screen recordings
https://github.com/neutralinojs/neutralinojs/assets/7458713/7deb2053-bd68-43c8-b343-8e61f1766330

Specifications

  • OS: manjaro linux
$ neofetch
β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ  β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ   mmc@manjaro 
β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ  β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ   ----------- 
β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ  β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ   OS: Manjaro Linux x86_64 
β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ  β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ   Host: HP ProDesk 480 G6 MT 
β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ            β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ   Kernel: 6.6.25-1-MANJARO 
β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ  β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ  β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ   Uptime: 17 hours, 20 mins 
β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ  β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ  β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ   Packages: 1339 (pacman) 
β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ  β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ  β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ   Shell: zsh 5.9 
β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ  β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ  β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ   Resolution: 1920x1080 
β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ  β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ  β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ   DE: Xfce 4.18 
β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ  β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ  β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ   WM: Xfwm4 
β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ  β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ  β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ   WM Theme: JacWin10 
β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ  β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ  β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ   Theme: Windows10 [GTK2/3] 
β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ  β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ  β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ   Icons: Faenza [GTK2/3] 
                              Terminal: terminator 
                              CPU: Intel i5-9500 (6) @ 4.400GHz 
                              GPU: Intel CoffeeLake-S GT2 [UHD Graphics 630] 
                              Memory: 6296MiB / 31941MiB
  • Neutralinojs version: 5.1.0
  • Neutralinojs client library version: 5.1.0
  • Neutralinojs CLI version: [e.g. v9.1.2]
$ neu version
 _   _            _             _ _             _     
| \ | | ___ _   _| |_ _ __ __ _| (_)_ __   ___ (_)___ 
|  \| |/ _ \ | | | __| '__/ _` | | | '_ \ / _ \| / __|
| |\  |  __/ |_| | |_| | | (_| | | | | | | (_) | \__ \
|_| \_|\___|\__,_|\__|_|  \__,_|_|_|_| |_|\___// |___/
                                             |__/     
--- Global ---
neu CLI: v11.0.1
neu: INFO Run this command inside your project directory to get project specific Neutralinojs version.

Try replacing "windowClose" with "beforeClose" in your code and see if it works as expected.

hi, not working, html code like this

<!DOCTYPE html>
<html>
  <head>
    <meta charset="UTF-8" />
    <title>Hello Neutralinojs</title>
    <style>
      body {
        background-color: white;
      }
    </style>
  </head>
  <body>
    It works πŸš€
    <script src="neutralino.js"></script>
    <script>
      Neutralino.init();
      Neutralino.events.on("ready", () => {
        Neutralino.os.showMessageBox("ready", "on ready");
      });
      Neutralino.events.on("beforeClose", () => {
        Neutralino.os.showMessageBox("close", "will close");
      });
    </script>
  </body>
</html>
neu run

ready msgbox popuped, nothing happened when i click close button