Skip to main content

Handler events

Every handler in the library takes one event object, never a positional argument list:

<Button onPress={({ player }) => player.sendMessage('hi')} />
<Slot onInsert={({ stack, host }) => count(host, stack)} />
<Form onSubmit={({ values }) => save(values)} />
TypeFieldsUsed by
UiEventplayer, host?, container?Form.onCancel
PressEventplayer, host?, container?Button.onPress
ContainerEventplayer, host, containerContainer.onOpen / onClose
SlotEventplayer, host, container, stackSlot.onInsert / onRemove
SubmitEventplayer, valuesForm.onSubmit

player is always the player the event is about: the viewer on a form, and on a container screen the player who moved the item. host is the entity or block that owns the screen, so it is present exactly on screens a host owns — always on a container screen, never on a form. container travels with host: it is that screen's own cells as the engine's own Container, addressed by index or by name, so a handler written inside the component reaches them without importing the screen object — see Reaching the cells. What a handler receives can gain a field without breaking a single call site, which is why it is an object rather than arguments.

Next steps​

On this page