miso
Copyright(C) 2016-2026 David M. Johnson
LicenseBSD3-style (see the file LICENSE)
MaintainerDavid M. Johnson <code@dmj.io>
Stabilityexperimental
Portabilitynon-portable
Safe HaskellNone
LanguageHaskell2010

Miso.Subscription.Mouse

Contents

Description

Overview

Miso.Subscription.Mouse provides a single global subscription, mouseSub, that fires on every pointermove event on window, delivering a PointerEvent carrying coordinates, pressure, pointer type, and other pointer metadata.

It is a thin convenience wrapper over windowSub "pointermove" pointerDecoder. Use windowPointerMoveSub directly if you need identical behaviour but prefer the window-level import.

Quick start

import Miso
import Miso.Subscription.Mouse
import Miso.Event.Types (PointerEvent(..))

data Action = MouseMoved PointerEvent

subs :: [Sub Action]
subs = [ mouseSub MouseMoved ]

update :: Action -> Effect p props Model Action
update (MouseMoved ev) = do
  let (cx, cy) = client ev   -- (clientX, clientY)
  ...

See also

Synopsis

Subscription

mouseSub Source #

Arguments

:: (PointerEvent -> action)

Callback fired with the full PointerEvent on every pointermove

-> Sub action 

Captures mouse coordinates as they occur and writes them to an event sink.