久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

dialog.showMessageBox 不返回電子 main.js 中的按鈕索引

dialog.showMessageBox not returning button index in electron main.js(dialog.showMessageBox 不返回電子 main.js 中的按鈕索引)
本文介紹了dialog.showMessageBox 不返回電子 main.js 中的按鈕索引的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

問題描述

我有一個消息框,當用戶單擊dashboardWindow 上的關閉時會打開一個消息框(Windows 操作系統右上角的X 按鈕)

I have a messagebox that will open when the user click close on dashboardWindow (X button top right on windows os)

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");
  });
}

當我關閉 dashboardWindow 時消息框打開,但我無法讓 response === 0 工作.即使沒有點擊按鈕,console.log("after message box"); 也已經運行.我怎樣才能做出響應(messageBox 上的返回索引按鈕)?

The messagebox opened when i close the dashboardWindow but i can't get response === 0 to work. Samehow console.log("after message box"); already run even when there is no click on the buttons. How I can make the response work (return index button on messageBox)?

登錄窗口關閉

推薦答案

請參考最新的 API 文檔關于 dialog.showMessageBox:此方法返回一個 Promise 對象并且不再使用回調函數,就像在 Electron v5.xx 之前一樣

Please refer to the most recent API doc about dialog.showMessageBox: this method returns a Promise object and doesn't make use of a callback function any more, like it used to until Electron v5.x.x.

Returns Promise - 使用包含以下屬性:

Returns Promise<Object> - resolves with a promise containing the following properties:

  • response Number - 點擊按鈕的索引.
  • checkboxChecked 布爾值 - 如果設置了 checkboxLabel,則復選框的選中狀態.否則 false.
  • response Number - The index of the clicked button.
  • checkboxChecked Boolean - The checked state of the checkbox if checkboxLabel was set. Otherwise false.

這應該可以工作(盡管在您的上下文中未經測試):

This should work then (untested in your context though):

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
      })
      .then(result => {
        if (result.response === 0) {
          // bound to buttons array
          console.log("Default button clicked.");
        } else if (result.response === 1) {
          // bound to buttons array
          console.log("Cancel button clicked.");
        }
      }
    );
    console.log("after message box");
  });

這篇關于dialog.showMessageBox 不返回電子 main.js 中的按鈕索引的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!

相關文檔推薦

How to fix BrowserWindow is not a constructor error when creating child window in Electron renderer process(在 Electron 渲染器進程中創建子窗口時如何修復 BrowserWindow 不是構造函數錯誤) - IT屋-程序員軟件開發技術
mainWindow.loadURL(quot;https://localhost:3000/quot;) show white screen on Electron app(mainWindow.loadURL(https://localhost:3000/) 在 Electron 應用程序上顯示白屏)
Electron webContents executeJavaScript : Cannot execute script on second on loadURL(Electron webContents executeJavaScript:無法在第二個 loadURL 上執行腳本)
how to use electron browser window inside components in angular-cli?(如何在angular-cli的組件內使用電子瀏覽器窗口?)
ElectronJS - sharing redux store between windows?(ElectronJS - 在 Windows 之間共享 redux 存儲?)
How to access camera/webcamera inside electron app?(如何在電子應用程序中訪問相機/網絡攝像頭?)
主站蜘蛛池模板: 欧美精品一区二 | 91新视频 | 久久香蕉精品 | 日本精品视频在线 | 精品国产一区二区三区久久久蜜月 | 国产在线一区二区三区 | 国产又粗又猛又黄又爽的视频 | 成人动漫在线看 | 天天射综合 | 免费观看一区二区三区毛片 | 久久男人天堂 | 麻豆做爰免费观看 | 四虎在线播放 | 日韩一区二区在线视频 | 日本中文字幕在线播放 | 狠狠干影院 | a一级黄色片| 亚洲精品网站在线观看 | 国产suv一区二区 | 国产91页| 久久久久黄色 | 日本成人中文字幕 | 亚洲小视频 | 久久精品99久久久久久 | 久草视| 黄色在线小视频 | 欧美在线| 成人在线a | 日韩专区在线观看 | 日韩成人三级 | av免费网站 | 综合色在线 | 成人毛片在线 | 国产黄色精品视频 | 中文在线观看视频 | 亚洲免费在线播放 | 国产日韩欧美 | 色网站在线观看 | 国产一区二区三区久久 | 国产福利91精品一区二区三区 | 六月婷婷综合 |