Esc

Desktop

moduleextensionexperimentalSource
  • macOS: Everything works on macOS
  • Linux: Everything works on Linux
  • Windows: Everything works on Windows
  • Wasm: Not available on Wasm
·since 0.36.1

#import "Extensions/Desktop";

Native menus, file dialogs and opt-in text services for desktop windows.

Procedures#

General#

valid_menuexperimentalsince 0.36.1Source
(items: [] Menu_Item) -> bool

Checks IDs, titles and shortcut uniqueness without contacting a window server.

Windows#

translate_acceleratorexperimentalsince 0.36.1Source
(message: *W.MSG) -> bool

Called before TranslateMessage; consumed accelerators must not also become keyboard/text input.

Events#

update_eventsexperimentalsince 0.36.1Source
()

Pumps Input while enabling this extension's menu shortcuts and IME decoding. Use in place of Input.update_window_events, once per frame, on the window thread. Other Input APIs are unchanged.

set_text_input_rectexperimentalsince 0.36.1Source
(window: WT.Window_Type, enabled: bool, x: float, y: float, height: float)

Enables composition and positions candidate UI at a caret in top-left window points. Disabling cancels marked text. Linux currently leaves native composition unsupported.

detach_text_inputexperimentalsince 0.36.1Source
(window: WT.Window_Type)

Restores the original native view class/window procedure before destroying the window. Also releases queued composition text belonging to it. Call on the window thread after the last frame.

Types#

Native_Menustructexperimentalsince 0.36.1Source

An owned menu installation, used on the window's thread. macOS allows one installation per application; Windows allows one per window. Remove it before destroying its window.

Native_Menu :: struct {
    window: WT.Window_Type;
    handle: *void;
    target: *void;
    accelerators: *void;
    previous: *void;
    pending: [..] u16;
}
Dialog_Kindenumexperimentalsince 0.36.1Source

OPEN selects an existing file; SAVE selects an output path; FOLDER selects a directory.

Dialog_Kind :: enum {
    OPEN;
    SAVE;
    FOLDER;
}
Dialog_Statusenumexperimentalsince 0.36.1Source

ACCEPTED, CANCELLED, UNSUPPORTED or FAILED. Cancellation must not invoke a fallback prompt.

Dialog_Status :: enum {
    ACCEPTED;
    CANCELLED;
    UNSUPPORTED;
    FAILED;
}
Dialog_Resultstructexperimentalsince 0.36.1Source

A dialog outcome with an owned UTF-8 path. Release path with Basic.free after using it.

Dialog_Result :: struct {
    status: Dialog_Status = .UNSUPPORTED;
    path: string;
}
Composition_Eventstructexperimentalsince 0.36.1Source

An owned composition update, ordered before Input.events_this_frame[position]. Text remains valid until the next update_events call. Cursor counts UTF-8 bytes; -1 means the text's end.

Composition_Event :: struct {
    window: WT.Window_Type;
    position: int;
    text: string;
    commit: bool;
    cancel: bool;
    cursor: int = -1;
}