ConstOptionalconfig: KaylaClickConfigOptional filters (button + action)
// 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)
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):
<Layer>with atransformprop (camera, zoom, scroll, rotation…), thenposis already transformed into the layer-local coordinate system.posis in world coordinates.Uses the rectangle bounds from useRect / underlying entity. Multiple
usePointercalls stack and run in declaration order.