module Monomer.Event.Util (
isShiftPressed,
isCtrlPressed,
isAltPressed,
isGUIPressed,
isOnClick,
isOnButtonAction,
isOnWheelScroll,
isOnKeyAction,
isOnTextInput,
isOnClipboard,
isOnFocus,
isOnBlur,
isOnEnter,
isOnMove,
isOnLeave,
isOnDrag,
isOnDrop,
checkKeyboard
) where
import Data.Maybe (fromMaybe)
import qualified Data.Map as M
import Monomer.Event.Core
import Monomer.Event.Keyboard
import Monomer.Event.Types
isGUIPressed :: KeyMod -> Bool
isGUIPressed :: KeyMod -> Bool
isGUIPressed KeyMod
mod = KeyMod -> Bool
_kmLeftGUI KeyMod
mod Bool -> Bool -> Bool
|| KeyMod -> Bool
_kmRightGUI KeyMod
mod
isCtrlPressed :: KeyMod -> Bool
isCtrlPressed :: KeyMod -> Bool
isCtrlPressed KeyMod
keyMod = KeyMod -> Bool
_kmLeftCtrl KeyMod
keyMod Bool -> Bool -> Bool
|| KeyMod -> Bool
_kmRightCtrl KeyMod
keyMod
isShiftPressed :: KeyMod -> Bool
isShiftPressed :: KeyMod -> Bool
isShiftPressed KeyMod
keyMod = KeyMod -> Bool
_kmLeftShift KeyMod
keyMod Bool -> Bool -> Bool
|| KeyMod -> Bool
_kmRightShift KeyMod
keyMod
isAltPressed :: KeyMod -> Bool
isAltPressed :: KeyMod -> Bool
isAltPressed KeyMod
keyMod = KeyMod -> Bool
_kmLeftAlt KeyMod
keyMod Bool -> Bool -> Bool
|| KeyMod -> Bool
_kmRightAlt KeyMod
keyMod
isOnClick :: SystemEvent -> Bool
isOnClick :: SystemEvent -> Bool
isOnClick Click{} = Bool
True
isOnClick SystemEvent
_ = Bool
False
isOnButtonAction :: SystemEvent -> Bool
isOnButtonAction :: SystemEvent -> Bool
isOnButtonAction ButtonAction{} = Bool
True
isOnButtonAction SystemEvent
_ = Bool
False
isOnWheelScroll :: SystemEvent -> Bool
isOnWheelScroll :: SystemEvent -> Bool
isOnWheelScroll WheelScroll{} = Bool
True
isOnWheelScroll SystemEvent
_ = Bool
False
isOnKeyAction :: SystemEvent -> Bool
isOnKeyAction :: SystemEvent -> Bool
isOnKeyAction KeyAction{} = Bool
True
isOnKeyAction SystemEvent
_ = Bool
False
isOnTextInput :: SystemEvent -> Bool
isOnTextInput :: SystemEvent -> Bool
isOnTextInput TextInput{} = Bool
True
isOnTextInput SystemEvent
_ = Bool
False
isOnClipboard :: SystemEvent -> Bool
isOnClipboard :: SystemEvent -> Bool
isOnClipboard Clipboard{} = Bool
True
isOnClipboard SystemEvent
_ = Bool
False
isOnFocus :: SystemEvent -> Bool
isOnFocus :: SystemEvent -> Bool
isOnFocus Focus{} = Bool
True
isOnFocus SystemEvent
_ = Bool
False
isOnBlur :: SystemEvent -> Bool
isOnBlur :: SystemEvent -> Bool
isOnBlur Blur{} = Bool
True
isOnBlur SystemEvent
_ = Bool
False
isOnEnter :: SystemEvent -> Bool
isOnEnter :: SystemEvent -> Bool
isOnEnter Enter{} = Bool
True
isOnEnter SystemEvent
_ = Bool
False
isOnMove :: SystemEvent -> Bool
isOnMove :: SystemEvent -> Bool
isOnMove Move{} = Bool
True
isOnMove SystemEvent
_ = Bool
False
isOnLeave :: SystemEvent -> Bool
isOnLeave :: SystemEvent -> Bool
isOnLeave Leave{} = Bool
True
isOnLeave SystemEvent
_ = Bool
False
isOnDrag :: SystemEvent -> Bool
isOnDrag :: SystemEvent -> Bool
isOnDrag Drag{} = Bool
True
isOnDrag SystemEvent
_ = Bool
False
isOnDrop :: SystemEvent -> Bool
isOnDrop :: SystemEvent -> Bool
isOnDrop Drop{} = Bool
True
isOnDrop SystemEvent
_ = Bool
False
checkKeyboard :: SystemEvent -> (KeyMod -> KeyCode -> KeyStatus -> Bool) -> Bool
checkKeyboard :: SystemEvent -> (KeyMod -> KeyCode -> KeyStatus -> Bool) -> Bool
checkKeyboard (KeyAction KeyMod
mod KeyCode
code KeyStatus
motion) KeyMod -> KeyCode -> KeyStatus -> Bool
testFn = KeyMod -> KeyCode -> KeyStatus -> Bool
testFn KeyMod
mod KeyCode
code KeyStatus
motion
checkKeyboard SystemEvent
_ KeyMod -> KeyCode -> KeyStatus -> Bool
_ = Bool
False