Keyboard and mouse input handling.
We allow scenes to define a collection of their own handlers for each event type:
:focus-gained-fns
:focus-lost-fns
:mouse-pressed-fns
:mouse-released-fns
:mouse-entered-fns
:mouse-exited-fns
:mouse-clicked-fns
:mouse-moved-fns
:mouse-dragged-fns
:mouse-wheel-fns
When an event occurs the handlers for that type are applied to the state in order. Most of the time you'll likely have at most one handler for each type, but it's sometimes very helpful to be able to split them out.
Keyboard and mouse input handling. We allow scenes to define a collection of their own handlers for each event type: - `:focus-gained-fns` - `:focus-lost-fns` - `:mouse-pressed-fns` - `:mouse-released-fns` - `:mouse-entered-fns` - `:mouse-exited-fns` - `:mouse-clicked-fns` - `:mouse-moved-fns` - `:mouse-dragged-fns` - `:mouse-wheel-fns` When an event occurs the handlers for that type are applied to the state in order. Most of the time you'll likely have at most one handler for each type, but it's sometimes very helpful to be able to split them out.
(default-key-pressed state e)
Prevent the default behaviour of esc closing the sketch and add the pressed key to the list of currently held keys.
Prevent the default behaviour of esc closing the sketch and add the pressed key to the list of currently held keys.
(default-key-released state e)
Remove the released key from the list of currently held keys.
Remove the released key from the list of currently held keys.
(default-mouse-pressed {:keys [scenes current-scene] :as state} e)
Check all :clickable?
sprites for collision with the mouse event,
apply the :on-click-fn
of all that have been licked on.
Check all `:clickable?` sprites for collision with the mouse event, apply the `:on-click-fn` of all that have been licked on.
(handler-reducer handler-fns-key
&
{:keys [default-handler]
:or {default-handler identity-handler}})
Returns a function which reduces across the collection of
handler-fns-key
functions in the current scene, applying each to
the accumulating state.
Returns a function which reduces across the collection of `handler-fns-key` functions in the current scene, applying each to the accumulating state.
(handler-reducer-with-events handler-fns-key
&
{:keys [default-handler]
:or {default-handler identity-handler}})
Returns a function which reduces across the collection of
handler-fns-key
functions in the current scene, applying each to
the accumulating state, passing in the event each time.
Returns a function which reduces across the collection of `handler-fns-key` functions in the current scene, applying each to the accumulating state, passing in the event each time.
(identity-handler state & _args)
Returns the state unchanged, optionally takes any number of additional arguments which it ignores.
Returns the state unchanged, optionally takes any number of additional arguments which it ignores.
(on-click sprite f)
Make a sprite :clickable?
by adding an :on-click-fn
to be invoked
by the default mouse-pressed handler.
Make a sprite `:clickable?` by adding an `:on-click-fn` to be invoked by the default mouse-pressed handler.
cljdoc is a website building & hosting documentation for Clojure/Script libraries
× close