@kayelaa/canvas API - v0.2.15
    Preparing search index...

    Variable usePointerConst

    usePointer: (
        onPointer: (
            pos: Vector2,
            type: KaylaClickType,
            action: KaylaPointerAction,
        ) => void,
        config?: KaylaClickConfig,
    ) => void = ...

    Registers a callback that runs whenever the entity has pointer events that's bound to entity/collides (inside its bounds).

    This hook MUST be called at the top level of a component function — never inside loops, conditions, nested functions, or callbacks. The call order of all hooks is strictly fixed across every refresh; reordering calls will corrupt internal state.

    Coordinate system note (very important since layers):

    • If this component lives inside a <Layer> with a transform prop (camera, zoom, scroll, rotation…), then pos is already transformed into the layer-local coordinate system.
    • The automatic hit-test rectangle check is also performed in layer-local space.
    • If there is no transform on the containing layer → pos is in world coordinates.

    Uses the rectangle bounds from useRect / underlying entity. Multiple usePointer calls stack and run in declaration order.

    Type Declaration

    // Classic button (no layer transform)
    usePointer((worldPos, type, action) => {
    if (action === "down" && type === "left") {
    onClick();
    }
    }, { type: "left", action: "down" });
    // Inside a zoomed/scrollable UI panel or map
    usePointer((localPos) => {
    // localPos is already correct for items inside this zoomed layer
    inventory.selectSlotAt(localPos);
    });

    useGlobalPointer — for pointer events anywhere (not bound to this entity)