electron-react アプリにテキスト入力フィールドがあります。windows.alert() は、特定の条件が与えられた状態の変更に関するアラートを介して使用されていました。しかし、アラートをスローした後、完全に別のフォームの入力テキスト フィールドでは、ユーザーはアプリケーションをクリックしてから再度入力しないとデータを入力できませんでした。
現在、electron の ipcRenderer と ipcMain を使用してアラートをスローする回避策がありますが、スタイルがアプリケーションの残りの部分とうまく一致しません。テキスト入力フィールドへのデータ入力をブロックしない windows.alert() を処理する方法はありますか? windows.alert() がテキスト入力へのデータ入力をブロックする原因は何ですか?
前のコード例:
function doSomething(value) {
let array = otherArray;
if (array.length == 0) {
//The below was blocking typing into <input> in a completely separate form.
window.alert("Please add expected value first")
}
}
preload.js および ipcMain の ipcRenderer を使用してコードを回避します。
function doSomething(value) {
let array = otherArray;
if (array.length == 0) {
window.api.send("send-alert", "Please add expected value first")
}
}
//in main.js
ipcMain.on("send-alert", (event, incomingMessage)=> {
let options = {
message: incomingMessage
}
dialog.showMessageBox(mainBrowserWindow, options)
}