+
+
+
+
+
In this demo, the ipcRenderer is used to send a message from the renderer process instructing the main process to launch the information dialog. Options may be provided for responses which can then be relayed back to the renderer process.
+
+
Note: The title property is not displayed in macOS.
+
+
An information dialog can contain an icon, your choice of buttons, title and message.
+
Renderer Process (JavaScript)
+
document.getElementById("information-dialog").addEventListener("click", () => {
+ ipcRenderer.send("information-dialog");
+});
+
+ipcRenderer.on("information-dialog-reply", (sender, index) => {
+ let message = 'You selected ';
+
+ if(index == 0) {
+ message += 'yes.'
+ } else {
+ message += 'no.'
+ }
+
+ document.getElementById("info-selection").innerText = message;
+});
+
Main Process (C#)
+
Electron.IpcMain.On("information-dialog", async (args) =>
+{
+ var options = new MessageBoxOptions("This is an information dialog. Isn't it nice?")
+ {
+ Type = MessageBoxType.info,
+ Title = "Information",
+ Buttons = new string[] { "Yes", "No" }
+ };
+
+ var result = await Electron.Dialog.ShowMessageBoxAsync(options);
+
+ var mainWindow = Electron.WindowManager.BrowserWindows.First();
+ Electron.IpcMain.Send(mainWindow, "information-dialog-reply", result.Response);
+});
+