CApplication
import { CApplication } from "canvas-toolkit-lib";Declared members
constructor(canvas: HTMLCanvasElement, paintDevice?: CApplicationPaintDevice);Creates the application for an HTML canvas element. @param canvas Canvas used for rendering and pointer input. @param paintDevice Optional paint device targeting the same canvas. Defaults to Canvas 2D. @throws Error if another CApplication instance already exists.
resizeCanvas(width: number, height: number, pixelRatio?: number): void;Resizes the logical viewport and its high resolution bitmap. Only top-level widgets already filling the old viewport follow its size.
destroy(): void;Destroys the application, removes browser event listeners and clears application-managed state.
static instance(): CApplication;Returns the current application instance. @returns Current application instance. @throws Error if no CApplication has been created.
static exists(): boolean;Checks whether an application instance exists. @returns `true` if a CApplication currently exists.
canvas(): HTMLCanvasElement;Returns the HTML canvas used by the application. @returns Application canvas element.
paintDevice(): CPaintDevice;Returns the paint device associated with the application canvas. @returns Application paint device.
topLevelWidgets(): readonly CWidget[];Returns the registered top-level widgets. @returns Snapshot of the top-level widget list.
font(): CFont;Returns the application default font. @returns Independent copy of the current font.
setFont(font: CFont): void;Sets the application default font and schedules a repaint. @param font Font to use as the application default.
palette(): CPalette;Returns the application palette. @returns Current application palette.
setPalette(palette: CPalette): void;Sets the palette inherited by widgets without local overrides and repaints. Reapplying the same instance also repaints, for example after CCssPalette.reload(). @param palette Palette to use.
style(): CStyle;Returns the application style. @returns Current application style.
setStyle(style: CStyle): void;Sets the application style and schedules a repaint. @param style Style to use.
registerTopLevelWidget(widget: CWidget): void;Registers a top-level widget. @param widget Parentless widget to register. @throws Error if the widget has a parent.
unregisterTopLevelWidget(widget: CWidget): void;Unregisters a top-level widget. @param widget Widget to unregister.
updatesEnabled(): boolean;Returns whether repaint updates are enabled. @returns `true` if updates are enabled.
focusWidget(): CWidget | null;Returns the widget that currently owns keyboard focus. @returns Focus widget, or `null` if none.
setFocusWidget(widget: CWidget | null): void;Changes the keyboard focus widget and dispatches focus-out/focus-in events. @param widget Widget to focus, or `null` to clear focus.
run(): void;Enables repaint updates and requests a repaint.
stopUpdates(): void;Disables repaint updates and cancels any pending animation frame.
requestRepaint(): void;Schedules a repaint on the next animation frame when updates are enabled.
grabMouse(widget: CWidget): void;Routes subsequent mouse events to a specific widget. @param widget Widget that should grab mouse input.
releaseMouse(): void;Releases the current mouse grab.
mouseGrabber(): CWidget | null;Returns the widget currently grabbing mouse input. @returns Mouse grabber, or `null`.
hoverWidget(): CWidget | null;Returns the widget currently under the pointer. @returns Hovered widget, or `null`.
closeAllPopups(): void;Closes all currently registered popup widgets.
popupWidgets(): readonly CPopupWidget[];Returns the registered popup widgets in stacking order. @returns Snapshot of the popup widget list.
registerPopupWidget(widget: CPopupWidget): void;Registers a popup widget and moves it to the top of the popup stack. @param widget Popup widget to register.
unregisterPopupWidget(widget: CPopupWidget): void;Unregisters a popup widget. @param widget Popup widget to unregister.
registerWindowWidget(widget: CWidget): void;Registers a window widget and moves it to the top of the window stack. @param widget Window widget to register.
unregisterWindowWidget(widget: CWidget): void;Unregisters a window widget. @param widget Window widget to unregister.
isWindowWidget(widget: CWidget): boolean;Checks whether a widget is registered as a window. @param widget Widget to test. @returns `true` if the widget is a registered window.
registerModalWidget(widget: CWidget): void;Registers a modal widget after closing open popups. @param widget Modal widget to register.
rememberNonModalFocus(dialog: CWidget): void;@internal Records focus before opening a non-modal dialog.
restoreNonModalFocus(dialog: CWidget, hadFocus: boolean): void;@internal Discards the saved focus and optionally restores it after hiding the dialog.
unregisterModalWidget(widget: CWidget): void;Unregisters a modal widget. @param widget Modal widget to unregister.
modalWidgets(): readonly CWidget[];Returns the registered modal widgets. @returns Snapshot of the modal widget stack.
topModalWidget(): CWidget | null;Returns the topmost modal widget. @returns Top modal widget, or `null` when no modal widget is registered.
toolTipVisible(): boolean;Returns whether a tooltip is currently visible. @returns `true` if a tooltip is visible.
focusNextWidget(forward?: boolean): boolean;Moves keyboard focus to the next or previous focusable widget. @param forward `true` to move forward; `false` to move backward. @returns `true` if focus was moved.
rememberFocusBeforeHide(subtree: CWidget): void;@internal Keeps the current tab position when a focused subtree is about to be hidden.
focusLabelBuddy(label: CWidget, buddy: CWidget): boolean;@internal Focus transfer shared by label clicks and Alt mnemonics.
setTabOrder(first: CWidget, second: CWidget): void;@internal Called by CWidget.setTabOrder().
activeDrag(): CDrag | null;Returns the active drag operation. @returns Active drag, or `null`.
dragTarget(): CWidget | null;Returns the current drag target widget. @returns Drag target, or `null`.
startDrag(drag: CDrag): void;Registers an already active drag operation with the application. @param drag Active drag operation to manage.
cancelDrag(): void;Cancels the active drag operation and notifies the current drag target.
clipboard(): CClipboard;Returns the application clipboard. @returns Application clipboard instance.