Gesso.Interactions.Internal
- Package
- purescript-gesso
- Repository
- smilack/purescript-gesso
Definitions of the Interaction type as well as event handlers and event listener HTML properties.
#EventProp Source
type EventProp event i = (event -> i) -> IProp HTMLcanvas i
An IProp
is an HTML property, with kind
IProp :: Row Type -> Type -> Type
, where the row type is the set of all
valid properties for the element that this property will be attached to.
Typically, an event listener type would look like this:
onMouseMove
:: forall r i
. (MouseEvent -> i)
-> IProp (onMouseMove :: MouseEvent | r) i
where the event type is predetermined and the row type is parameterized to
allow any element with an onMouseMove
property.
This generic EventProp
is the inverse: parameterized to allow any event
type, but the property must be a valid property of the HTMLcanvas
row.
#Handler Source
type Handler event state = event -> UpdateFunction state
An event handler is a variant of an update function, which receives an event and produces an update function in response.
#Interaction Source
data Interaction event state
An Interaction is a combination event listener and handler which is turned
into an HTML property and attached to a Gesso canvas. They can be
constructed with the "on
" functions (onMouseMove
, onKeyDown
, etc.)
Constructors
Interaction (forall i. EventProp event i) (Handler event state)
#Interactions Source
type Interactions state = { base :: Array (Interaction Event state), clipboard :: Array (Interaction ClipboardEvent state), drag :: Array (Interaction DragEvent state), focus :: Array (Interaction FocusEvent state), keyboard :: Array (Interaction KeyboardEvent state), mouse :: Array (Interaction MouseEvent state), pointer :: Array (Interaction PointerEvent state), touch :: Array (Interaction TouchEvent state), wheel :: Array (Interaction WheelEvent state) }
Interactions
is a record containing arrays of interactions for each type
of event that Canvas supports. It's used in
Gesso.Application.AppBehavior
to add event handlers to a component.
#toProps Source
toProps :: forall state i. (UpdateFunction state -> i) -> Interactions state -> Array (IProp HTMLcanvas i)
Convert an Interactions
record to an array of HTML properties. The return
value of the toCallback
parameter, i
, is only known by the component
and should be whatever Action
type the component has, like QueueUpdate
in Canvas.
Re-exports from Web.Clipboard.ClipboardEvent
#ClipboardEvent Source
data ClipboardEvent
Re-exports from Web.Event.Internal.Types
Re-exports from Web.HTML.Event.DragEvent
Re-exports from Web.PointerEvent
#PointerEvent Source
data PointerEvent
Re-exports from Web.TouchEvent.TouchEvent
#TouchEvent Source
data TouchEvent
Re-exports from Web.UIEvent.FocusEvent
#FocusEvent Source
data FocusEvent
Re-exports from Web.UIEvent.KeyboardEvent
#KeyboardEvent Source
data KeyboardEvent
Re-exports from Web.UIEvent.MouseEvent
#MouseEvent Source
data MouseEvent
Re-exports from Web.UIEvent.WheelEvent
#WheelEvent Source
data WheelEvent