小编Wah*_*Feb的帖子

dialog.showMessageBox 不返回电子 main.js 中的按钮索引

我有一个消息框,当用户在dashboardWindow 上单击关闭时将打开该消息框(Windows 操作系统右上角的 X 按钮)

dashboardWindow.on("close", (event) => {
    event.preventDefault();
    console.log("before message box");
    dialog.showMessageBox(
      dashboardWindows,
      {
        message: "Test",
        buttons: ["Default Button", "Cancel Button"],
        defaultId: 0, // bound to buttons array
        cancelId: 1 // bound to buttons array
      },
      (response) => {
        if (response === 0) {
          // bound to buttons array
          console.log("Default button clicked.");
        } else if (response === 1) {
          // bound to buttons array
          console.log("Cancel button clicked.");
        }
      }
    );
    console.log("after message box");
  });
}
Run Code Online (Sandbox Code Playgroud)

当我关闭 dashboardWindow 时消息框打开,但我无法开始 …

javascript dialog messagebox callback electron

4
推荐指数
1
解决办法
4444
查看次数

标签 统计

callback ×1

dialog ×1

electron ×1

javascript ×1

messagebox ×1