On my top level div, I have
HE.onMouseUp $ HE.input_ $ MouseUp_Anywhere
And for a small area of the window (moveSquare x), I also have
HE.onMouseUp $ HE.input_ $ MouseUp_MoveSquare x
In eval
, I have this:
MouseUp_Anywhere next -> do
H.modify (_ {mouseDown_MoveSquare = Nothing})
pure next
MouseUp_MoveSquare x next -> do
mouseDown_MoveSquare <- H.gets _.mouseDown_MoveSquare
when (mouseDown_MoveSquare == Just x) do
newMove = ...
H.modify (_ {move = newMove})
pure next
Question: This code actually works fine (thus far), but is it valid (i.e., reliable)? The MouseUp_Anywhere
also kicks in for MouseUp_MoveSquare
yet seems to always be called second, because I reliably test against a valid H.gets _.mouseDown_MoveSquare
, even though it gets set to Nothing
when handling MouseUp_Anywhere
. The advantage of this technique (if in fact valid) is that it allows me to avoid doing testing with mousePos
.