[reactive] Missing key-events and scanlB

Mads Lindstrøm mads_lindstroem at yahoo.dk
Sun Mar 29 15:35:23 EDT 2009


Hi

I am trying to make a Behavior, which contains the last pressed key and
the distance the mouse traveled since the key was pressed. I programmed
this function:

charAndRelativeMousePos :: Anim (Maybe (Char, (Double, Double)))
charAndRelativeMousePos u
    = scanlB (\r _ -> r) (pure Nothing) (snapshotWith char (mousePosition u) (keyAction u))
      where
        char (_, Char ch) m = (\newMouse -> Just (ch, newMouse - m)) <$> mousePosition u
        char _ _            = pure Nothing


Unfortunately it is not working. If I move the mouse before pressing a
key, then it takes a long time before recognizing the first key-press.
And it only recognizes the first key-press, never the second, nor
third, ...

What am I doing wrong ?

I think maybe it has something to do me using "mousePosition u" twice.
Am I hanging on to tons of mouse-position, due to the second use of
mousePosistion ?

A complete program using the charAndRelativeMousePos function can be
seen here http://hpaste.org/fastcgi/hpaste.fcgi/view?id=3062#a3062 .


Greetings,

Mads Lindstrøm





More information about the Reactive mailing list