{-# OPTIONS_HADDOCK hide #-}
{-# LANGUAGE RankNTypes #-}
module Graphics.Gloss.Internals.Interface.ViewState.KeyMouse
(callback_viewState_keyMouse)
where
import Graphics.Gloss.Data.ViewState
import Graphics.Gloss.Internals.Interface.Backend
import Graphics.Gloss.Internals.Interface.Event
import Data.IORef
callback_viewState_keyMouse
:: IORef ViewState
-> Callback
callback_viewState_keyMouse :: IORef ViewState -> Callback
callback_viewState_keyMouse IORef ViewState
viewStateRef
= KeyboardMouseCallback -> Callback
KeyMouse (IORef ViewState -> KeyboardMouseCallback
viewState_keyMouse IORef ViewState
viewStateRef)
viewState_keyMouse :: IORef ViewState -> KeyboardMouseCallback
viewState_keyMouse :: IORef ViewState -> KeyboardMouseCallback
viewState_keyMouse IORef ViewState
viewStateRef IORef a
stateRef Key
key KeyState
keyState Modifiers
keyMods (Int, Int)
pos
= do ViewState
viewState <- IORef ViewState -> IO ViewState
forall a. IORef a -> IO a
readIORef IORef ViewState
viewStateRef
Event
ev <- IORef a -> Key -> KeyState -> Modifiers -> (Int, Int) -> IO Event
forall a.
Backend a =>
IORef a -> Key -> KeyState -> Modifiers -> (Int, Int) -> IO Event
keyMouseEvent IORef a
stateRef Key
key KeyState
keyState Modifiers
keyMods (Int, Int)
pos
case Event -> ViewState -> Maybe ViewState
updateViewStateWithEventMaybe Event
ev ViewState
viewState of
Maybe ViewState
Nothing -> () -> IO ()
forall (m :: * -> *) a. Monad m => a -> m a
return ()
Just ViewState
viewState'
-> do IORef ViewState
viewStateRef IORef ViewState -> ViewState -> IO ()
forall a. IORef a -> a -> IO ()
`writeIORef` ViewState
viewState'
IORef a -> IO ()
forall a. Backend a => IORef a -> IO ()
postRedisplay IORef a
stateRef