# new RezEventProcessor()
Processes events in the Rez game engine. Handles browser events (clicks, inputs, submits), custom game events, timer events, and system events. Routes events to appropriate handlers and manages the event lifecycle including system pre/post processing and undo manager integration.
Methods
# afterEventProcessing(evt, result) → {*}
Runs the event result through all enabled systems' after_event handlers. Each system can modify the result after the event has been processed.
Parameters:
| Name | Type | Description |
|---|---|---|
evt |
Event
|
the original browser event |
result |
*
|
the result from event processing |
if any system handler doesn't return a valid result object
Error
the processed result
*
# beforeEventProcessing(evt) → {Event}
Runs the event through all enabled systems' before_event handlers. Each system can modify the event before it gets processed.
Parameters:
| Name | Type | Description |
|---|---|---|
evt |
Event
|
the browser event to pre-process |
if any system handler doesn't return a valid event object
Error
the processed event
Event
# constructor(game)
Creates a new event processor for the specified game
Parameters:
| Name | Type | Description |
|---|---|---|
game |
RezGame
|
the game instance this processor belongs to |
# decodeEvent(evt) → {Array}
Extracts event name, target, and parameters from an element's dataset attributes
Parameters:
| Name | Type | Description |
|---|---|---|
evt |
Event
|
the browser event to decode |
[eventName, target, params] decoded from the event's dataset
Array
# dispatchResponse(response)
Processes a RezEvent response by executing the actions it specifies: flash messages, scene changes/interludes/resumes, card plays, view renders, and error handling.
Parameters:
| Name | Type | Description |
|---|---|---|
response |
RezEvent
|
the event response to process |
if the response is not a RezEvent instance
Error
# getEventHandler(eventName) → {Array}
Finds an event handler by checking card, scene, and game in that order. Returns the first receiver that has a handler for the event.
Parameters:
| Name | Type | Description |
|---|---|---|
eventName |
string
|
the name of the event to find a handler for |
[receiver, handler] pair where receiver is the object that handles the event
Array
# getReceiverEventHandler(receiver, eventname) → {function|null}
Gets an event handler function from a receiver object
Parameters:
| Name | Type | Description |
|---|---|---|
receiver |
*
|
the object to check for event handlers |
eventname |
string
|
the name of the event to find a handler for |
the event handler function or null if not found
function
|
null
# handleBrowserClickEvent(evt) → {*}
Handles browser click events by decoding the event data and routing to appropriate handlers. Supports built-in event types (card, switch, interlude, resume) and custom events.
Parameters:
| Name | Type | Description |
|---|---|---|
evt |
Event
|
the click event |
the result of handling the click event
*
# handleBrowserEvent(evt) → {*}
Main event handler that processes browser events. Handles undo recording, system pre/post processing, and routes events to specific handlers based on type.
Parameters:
| Name | Type | Description |
|---|---|---|
evt |
Event
|
the browser event to handle |
the result of processing the event
*
# handleBrowserInputEvent(evt) → {RezEvent}
Handles browser input events by finding the card that contains the input element and calling its input event handler.
Parameters:
| Name | Type | Description |
|---|---|---|
evt |
Event
|
the input event |
if the card container or card ID cannot be found
Error
the result of the card's input event handler
# handleBrowserSubmitEvent(evt) → {RezEvent}
Handles browser form submit events by finding the card that contains the form and calling its event handler named after the form.
Parameters:
| Name | Type | Description |
|---|---|---|
evt |
Event
|
the submit event |
if the form name or card container cannot be found
Error
the result of the card's form event handler
# handleCardEvent(target, params) → {RezEvent}
Handles built-in card events that play a specific card
Parameters:
| Name | Type | Description |
|---|---|---|
target |
string
|
ID of the card to play |
params |
object
|
parameters to pass to the card |
event that plays the specified card
# handleCustomEvent(eventName, params) → {RezEvent}
Handles custom events by finding and calling the appropriate event handler
Parameters:
| Name | Type | Description |
|---|---|---|
eventName |
string
|
the name of the custom event |
params |
object
|
parameters to pass to the event handler |
the result of the event handler or an error event
# handleInterludeEvent(target, params) → {RezEvent}
Handles built-in interlude events that interrupt the current scene
Parameters:
| Name | Type | Description |
|---|---|---|
target |
string
|
ID of the scene to interlude with |
params |
object
|
parameters to pass to the scene |
event that starts an interlude with the specified scene
# handleKeyBindingEvent(evt) → {*}
Handles key binding events by routing them to custom event handlers
Parameters:
| Name | Type | Description |
|---|---|---|
evt |
CustomEvent
|
the key binding event with event name details |
the result of handling the key binding event
*
# handleResumeEvent(params) → {RezEvent}
Handles built-in resume events that return to the previous scene
Parameters:
| Name | Type | Description |
|---|---|---|
params |
object
|
parameters to pass to the resumed scene |
event that resumes the previous scene
# handleSwitchEvent(target, params) → {RezEvent}
Handles built-in switch events that change to a new scene
Parameters:
| Name | Type | Description |
|---|---|---|
target |
string
|
ID of the scene to switch to |
params |
object
|
parameters to pass to the scene |
event that changes to the specified scene
# handleTimerEvent(evt) → {*}
Handles timer events by routing them to custom event handlers
Parameters:
| Name | Type | Description |
|---|---|---|
evt |
CustomEvent
|
the timer event with timer details |
the result of handling the timer event
*
# handleWindowEvent(evt) → {*}
Handles window events by routing them to custom event handlers with the "window_" prefix (e.g. "wheel" becomes "window_wheel")
Parameters:
| Name | Type | Description |
|---|---|---|
evt |
CustomEvent
|
the window event with event name and browser event details |
the result of handling the window event
*
# isAutoUndoEvent(evt) → {boolean}
Determines if an event should automatically record undo state
Parameters:
| Name | Type | Description |
|---|---|---|
evt |
Event
|
the event to check |
true if this event type should trigger automatic undo recording
boolean
# raiseKeyBindingEvent(event_name) → {*}
Creates and processes a custom key binding event
Parameters:
| Name | Type | Description |
|---|---|---|
event_name |
string
|
the name of the key binding event |
the result of processing the key binding event
*
# raiseTimerEvent(timer) → {*}
Creates and processes a custom timer event
Parameters:
| Name | Type | Description |
|---|---|---|
timer |
RezTimer
|
the timer that fired |
the result of processing the timer event
*
# raiseWindowEvent(eventName, browserEvt) → {*}
Creates and processes a custom window event that wraps a native browser event
Parameters:
| Name | Type | Description |
|---|---|---|
eventName |
string
|
the name of the window event (e.g. "wheel", "resize") |
browserEvt |
Event
|
the native browser event |
the result of processing the window event
*