    {-# 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 to handle keyboard and mouse button events
    --      for controlling the 'ViewState'.
    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 <- IORef ViewState -> IO ViewState
    forall a. IORef a -> IO a
    readIORef IORef ViewState
    viewStateRef
            ev        <- keyMouseEvent stateRef key keyState keyMods pos
            case updateViewStateWithEventMaybe ev viewState of
                    Maybe ViewState
    Nothing -> () -> IO ()
    forall a. a -> IO a
    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