Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

windowClose event not triggered #1246

Closed
ziyouchutuwenwu opened this issue Apr 10, 2024 · 3 comments
Closed

windowClose event not triggered #1246

ziyouchutuwenwu opened this issue Apr 10, 2024 · 3 comments
Assignees
Labels
bug Something isn't working
Milestone

Comments

@ziyouchutuwenwu
Copy link

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.
@ziyouchutuwenwu ziyouchutuwenwu added the bug Something isn't working label Apr 10, 2024
@aniketkumar7
Copy link

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

@ziyouchutuwenwu
Copy link
Author

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

@shalithasuranga
Copy link
Member

Hello, please use "exitProcessOnClose": false, in your config when you use the windowClose event. Thanks 🎉 The default for exitProcessOnClose is true that's why the event won't fire during the window close action.

@shalithasuranga shalithasuranga added this to the Next milestone May 27, 2024
@shalithasuranga shalithasuranga self-assigned this May 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants