Events
Namespace: web.events
Overview
The web.events namespace provides event handler properties that fire in response to native Windows events. Unlike most WebExeBuilder APIs which are called as functions, events are assigned as callback functions:
web.events.onSomeEvent = function(arg) { ... };
Register handlers inside DOMContentLoaded to ensure the web.* API is available.
Available Events
| Event | Fires when... |
|---|---|
onFileDrop |
User drags files from Explorer and drops onto the app window |
onNotificationClick |
User clicks a system tray notification shown via web.system.notification |
onAppMenuItemClick |
User clicks a native menu bar item created via web.appMenu.createMenu |
onTrayMenuItemClick |
User clicks a system tray menu item created via web.trayMenu.createMenu |
onHotkey |
A registered global hotkey is pressed anywhere in Windows |
onCloseQuery |
User tries to close the application window |
Pattern
document.addEventListener('DOMContentLoaded', () => {
// Assign handler — fires whenever the event occurs
web.events.onFileDrop = function(paths) {
console.log('Dropped:', paths);
};
web.events.onNotificationClick = function(name) {
console.log('Notification clicked:', name);
};
web.events.onHotkey = function(hotkeyId) {
console.log('Global hotkey pressed:', hotkeyId);
};
});
Note on
onAppMenuItemClick: Menu event handlers must be set in the Builder's "BEFORE DOM Exists JS" slot, not inside the HTML page. Seeweb.appMenudocumentation for details.
Note on
onHotkey: Requires at least one hotkey registered viaweb.hotkey.register(). Seeweb.hotkeydocumentation for details.