move ball on click without drag

This commit is contained in:
nek0 2019-09-30 03:38:20 +02:00
parent c060a7f740
commit 6a4f1abe8c

View file

@ -217,7 +217,7 @@ networkDescription (listenerah, _) rotvar transvar = mdo
emouse <- fromAddHandler =<< registerMouseEvent passfire mouseah emouse <- fromAddHandler =<< registerMouseEvent passfire mouseah
epass <- fromAddHandler =<< registerPassEvent passah epass <- fromAddHandler =<< registerPassEvent passah
eClickHold <- fromAddHandler =<< registerClickHoldEvent passfire clickholdah eClickHold <- fromAddHandler =<< registerClickHoldEvent passfire clickholdah
clickHoldBehaviour <- RBC.stepper True eClickHold clickHoldBehaviour <- RBC.stepper False eClickHold
mouseMoveBehaviour <- RBC.stepper (V2 1 1) epass mouseMoveBehaviour <- RBC.stepper (V2 1 1) epass
let moveReaction = fmap (\x -> do let moveReaction = fmap (\x -> do
let input = (\(V2 xx _) -> let input = (\(V2 xx _) ->
@ -270,7 +270,6 @@ registerListenerEvent listenerah mousefire clickholdfire = do
if null filteredClickEvents if null filteredClickEvents
then then
return () return ()
-- clickholdfire False
else else
clickholdfire clickholdfire
(any (\x -> SDL.Pressed == SDL.mouseButtonEventMotion (any (\x -> SDL.Pressed == SDL.mouseButtonEventMotion
@ -309,10 +308,7 @@ registerClickHoldEvent
-> AddHandler Bool -> AddHandler Bool
-> m (AddHandler Bool) -> m (AddHandler Bool)
registerClickHoldEvent passfire clickholdah = do registerClickHoldEvent passfire clickholdah = do
void $ liftIO $ register clickholdah $ \x -> if x void $ liftIO $ register clickholdah $ \_ -> do
then do SDL.P vect <- SDL.getAbsoluteMouseLocation
SDL.P vect <- SDL.getAbsoluteMouseLocation passfire $ fmap fromIntegral vect
passfire $ fmap fromIntegral vect
else
return ()
return clickholdah return clickholdah