meo-skia-canvas
    Preparing search index...

    Type Alias WindowEvents

    Every event a Window emits, and what each one carries. The object a handler receives also has type and target alongside these fields.

    🧪 Not in the HTML Canvas standard.

    type WindowEvents = {
        blur: {};
        close: {};
        draw: { frame: number };
        focus: {};
        frame: { frame: number };
        fullscreen: { enabled: boolean };
        input: { data: string; inputType: TextInputType };
        keydown: KeyboardEventProps;
        keyup: KeyboardEventProps;
        mousedown: MouseEventProps;
        mousemove: MouseEventProps;
        mouseup: MouseEventProps;
        move: { left: number; top: number };
        resize: { height: number; width: number };
        setup: {};
        wheel: { deltaX: number; deltaY: number };
    }
    Index
    blur: {}

    The window lost keyboard focus.

    close: {}

    The window has closed.

    draw: { frame: number }

    As frame, but the context is reset first, so each handler starts from a blank canvas with default state. Listening for this at all is what turns the clearing on; frame alone leaves the previous frame in place to be drawn over.

    Type Declaration

    • frame: number

      How many frames have been drawn, counting from 0.

    focus: {}

    The window gained keyboard focus.

    frame: { frame: number }

    A new frame is due, numbered from 0. This is where to draw an animation: the canvas is presented after the handler returns.

    Type Declaration

    • frame: number

      How many frames have been drawn, counting from 0.

    fullscreen: { enabled: boolean }

    The window entered or left fullscreen.

    Type Declaration

    • enabled: boolean

      Whether the window is now fullscreen.

    input: { data: string; inputType: TextInputType }

    Text was entered, by keystroke or by input method. data is what was inserted, and inputType what kind of edit it was.

    Type Declaration

    • data: string

      The text that was inserted.

    • inputType: TextInputType

      What kind of edit produced it.

    A key went down, auto-repeats included.

    A key came up.

    mousedown: MouseEventProps

    A mouse button went down.

    mousemove: MouseEventProps

    The cursor moved over the window.

    A mouse button came up.

    move: { left: number; top: number }

    The window was moved, reporting its new screen position.

    Type Declaration

    • left: number

      The window's new distance from the left of the screen, in points.

    • top: number

      The window's new distance from the top of the screen, in points.

    resize: { height: number; width: number }

    The window was resized, reporting its new size in points.

    Type Declaration

    • height: number

      The window's new height, in points.

    • width: number

      The window's new width, in points.

    setup: {}

    Emitted once, immediately before the first frame event, for one-time initialization.

    wheel: { deltaX: number; deltaY: number }

    The scroll wheel or trackpad moved, in pixels.

    Type Declaration

    • deltaX: number

      Horizontal scroll since the last event, in pixels.

    • deltaY: number

      Vertical scroll since the last event, in pixels.