Calls Reference

ESDK exposes a set of native JavaScript bindings that let your frontend HTML control the OS window and communicate with the C++ and Python layers. All bindings are available globally on the window object and are injected before window.onload fires.

Window Control

windowClose()

returns: void

Posts WM_CLOSE to the native window handle, triggering the standard OS close flow (prompts the user if the app intercepts it). Equivalent to clicking the window's × button.

// Close button in a custom titlebar
document.getElementById('btn-close').addEventListener('click', function () {
    if (window.windowClose) window.windowClose();
});

windowMinimize()

returns: void

Minimizes the app window to the taskbar. Has no effect if the window style does not include WS_MINIMIZEBOX (controlled by CAN_MINIMIZE in properties.config).

if (window.windowMinimize) window.windowMinimize();

windowMaximize()

returns: void

Toggles the window between maximized and restored states. If the window is currently maximized, calling this restores it to its previous size and position.

// Toggle button
document.getElementById('btn-maximize').addEventListener('click', function () {
    if (window.windowMaximize) window.windowMaximize();
});

dragWindow()

returns: void

Initiates a native window drag. Bind it to onmousedown on any element you want to act as a drag handle (typically a custom titlebar region). The drag ends automatically when the mouse button is released.

<!-- Drag region in a custom titlebar -->
<div class="titlebar-drag"
     onmousedown="if(window.dragWindow) window.dragWindow()"
     style="position:absolute;inset:0;z-index:0;cursor:move;">
</div>

Modal System

openModal(name)

returns: Promise<any>

Opens ui/modals/<name>.html as a new native OS window on its own thread. The Promise resolves when the modal calls closeModal(value). If the modal file is not found, the Promise resolves with null.

ParameterTypeDescription
namestringName of the modal file without the .html extension (e.g. "alert", "prompt").
// Simple usage
await window.openModal('alert');

// With a return value
const result = await window.openModal('prompt');
if (result !== null) {
    console.log('User entered:', result);
}

// Confirm dialog
const confirmed = await window.openModal('confirm-delete');
if (confirmed) deleteItem();

closeModal(value)

modal-only · returns: void

Closes the current modal OS window and resolves the parent window's Promise with value. Only available inside a modal's <script> block — it is not a global binding in the main window.

ParameterTypeDescription
valueanyThe value forwarded to openModal().then(). Pass null to indicate cancellation.
// Inside ui/modals/my-modal.html <script>
function Submit() {
    var text = document.getElementById('input').value;
    closeModal(text);        // resolves with the user's text
}
function Cancel() {
    closeModal(null);        // resolves with null
}

Backend Bridge

invokeBridge(payload)

returns: Promise<object>

Sends a JSON payload through the C++ bridge to server/api.py's handle_message() function and returns the Python response as a parsed object. The action field is used by the server to route the request.

ParameterTypeDescription
payloadobjectA JS object with at minimum an action field. Additional fields are passed to the Python handler.
// Ping the backend
const response = await window.invokeBridge({ action: 'ping', data: 'hello' });
console.log(response.result); // "Pong! I received: hello"

// Call a public module
const res = await window.invokeBridge({ action: 'public_demo', name: 'Xavier' });
if (res.status === 'ok') {
    console.log(res.result);
}

Navigation & Links

openExternalLink(url)

returns: void

Opens a URL in the user's default system browser via ShellExecuteA. All <a href="https://..."> clicks in the webview are intercepted automatically and routed through this binding — you don't need to call it manually for standard links.

ParameterTypeDescription
urlstringA fully-qualified http:// or https:// URL.
// All  clicks are intercepted automatically.
// Call directly only for programmatic navigation:
if (window.openExternalLink) {
    window.openExternalLink('https://ecxogames.ca');
}

Quick Reference

Call Available In Returns Notes
windowClose()Main windowvoidPosts WM_CLOSE
windowMinimize()Main windowvoidRequires CAN_MINIMIZE
windowMaximize()Main windowvoidToggles maximize/restore
dragWindow()Main window & modalsvoidBind to onmousedown
openModal(name)Main windowPromise<any>Opens native OS window
closeModal(value)Modal windows onlyvoidResolves parent Promise
invokeBridge(payload)Main windowPromise<object>Calls server/api.py
openExternalLink(url)Main windowvoidAuto-wired to <a href>