Files
Electron.NET/ElectronNET.WebApp/Controllers/ShortcutsController.cs

30 lines
945 B
C#
Raw Normal View History

using ElectronNET.API;
using ElectronNET.API.Entities;
using Microsoft.AspNetCore.Mvc;
2017-11-10 02:12:13 +01:00
using System.Threading.Tasks;
namespace ElectronNET.WebApp.Controllers
{
public class ShortcutsController : Controller
{
public IActionResult Index()
{
2017-10-23 21:24:05 +02:00
if (HybridSupport.IsElectronActive)
{
Electron.GlobalShortcut.Register("CommandOrControl+Alt+K", async () =>
{
2017-10-23 21:24:05 +02:00
var options = new MessageBoxOptions("You pressed the registered global shortcut keybinding.")
{
Type = MessageBoxType.info,
Title = "Success!"
};
2017-10-23 21:24:05 +02:00
await Electron.Dialog.ShowMessageBoxAsync(options);
});
2018-01-24 22:44:27 +01:00
Electron.App.WillQuit += arg => Task.Run(() => Electron.GlobalShortcut.UnregisterAll());
2017-10-23 21:24:05 +02:00
}
return View();
}
}
}