{-# LANGUAGE PatternSynonyms #-}
{-# LANGUAGE ImplicitParams, ConstraintKinds, KindSignatures #-}
{-# OPTIONS_GHC -fno-warn-unused-imports #-}
module JSDOM.Generated.KeyboardEvent
(newKeyboardEvent, getModifierState, getModifierState_,
initKeyboardEvent, pattern DOM_KEY_LOCATION_STANDARD,
pattern DOM_KEY_LOCATION_LEFT, pattern DOM_KEY_LOCATION_RIGHT,
pattern DOM_KEY_LOCATION_NUMPAD, getKey, getCode, getLocation,
getCtrlKey, getShiftKey, getAltKey, getMetaKey, getRepeat,
getIsComposing, getKeyIdentifier, getKeyLocation, getAltGraphKey,
getCharCode, getKeyCode, getWhich, KeyboardEvent(..),
gTypeKeyboardEvent)
where
import Prelude ((.), (==), (>>=), return, IO, Int, Float, Double, Bool(..), Maybe, maybe, fromIntegral, round, realToFrac, fmap, Show, Read, Eq, Ord, Maybe(..))
import qualified Prelude (error)
import Data.Typeable (Typeable)
import Data.Traversable (mapM)
import Language.Javascript.JSaddle (JSM(..), JSVal(..), JSString, strictEqual, toJSVal, valToStr, valToNumber, valToBool, js, jss, jsf, jsg, function, asyncFunction, new, array, jsUndefined, (!), (!!))
import Data.Int (Int64)
import Data.Word (Word, Word64)
import JSDOM.Types
import Control.Applicative ((<$>))
import Control.Monad (void)
import Control.Lens.Operators ((^.))
import JSDOM.EventTargetClosures (EventName, unsafeEventName, unsafeEventNameAsync)
import JSDOM.Enums
newKeyboardEvent ::
(MonadDOM m, ToJSString type') =>
type' -> Maybe KeyboardEventInit -> m KeyboardEvent
newKeyboardEvent type' eventInitDict
= liftDOM
(KeyboardEvent <$>
new (jsg "KeyboardEvent") [toJSVal type', toJSVal eventInitDict])
getModifierState ::
(MonadDOM m, ToJSString keyArg) =>
KeyboardEvent -> keyArg -> m Bool
getModifierState self keyArg
= liftDOM
((self ^. jsf "getModifierState" [toJSVal keyArg]) >>= valToBool)
getModifierState_ ::
(MonadDOM m, ToJSString keyArg) => KeyboardEvent -> keyArg -> m ()
getModifierState_ self keyArg
= liftDOM (void (self ^. jsf "getModifierState" [toJSVal keyArg]))
initKeyboardEvent ::
(MonadDOM m, ToJSString type', ToJSString keyIdentifier) =>
KeyboardEvent ->
Maybe type' ->
Bool ->
Bool ->
Maybe Window ->
Maybe keyIdentifier ->
Maybe Word -> Bool -> Bool -> Bool -> Bool -> Bool -> m ()
initKeyboardEvent self type' canBubble cancelable view
keyIdentifier location ctrlKey altKey shiftKey metaKey altGraphKey
= liftDOM
(void
(self ^. jsf "initKeyboardEvent"
[toJSVal type', toJSVal canBubble, toJSVal cancelable,
toJSVal view, toJSVal keyIdentifier, toJSVal location,
toJSVal ctrlKey, toJSVal altKey, toJSVal shiftKey, toJSVal metaKey,
toJSVal altGraphKey]))
pattern DOM_KEY_LOCATION_STANDARD = 0
pattern DOM_KEY_LOCATION_LEFT = 1
pattern DOM_KEY_LOCATION_RIGHT = 2
pattern DOM_KEY_LOCATION_NUMPAD = 3
getKey ::
(MonadDOM m, FromJSString result) => KeyboardEvent -> m result
getKey self = liftDOM ((self ^. js "key") >>= fromJSValUnchecked)
getCode ::
(MonadDOM m, FromJSString result) => KeyboardEvent -> m result
getCode self = liftDOM ((self ^. js "code") >>= fromJSValUnchecked)
getLocation :: (MonadDOM m) => KeyboardEvent -> m Word
getLocation self
= liftDOM (round <$> ((self ^. js "location") >>= valToNumber))
getCtrlKey :: (MonadDOM m) => KeyboardEvent -> m Bool
getCtrlKey self = liftDOM ((self ^. js "ctrlKey") >>= valToBool)
getShiftKey :: (MonadDOM m) => KeyboardEvent -> m Bool
getShiftKey self = liftDOM ((self ^. js "shiftKey") >>= valToBool)
getAltKey :: (MonadDOM m) => KeyboardEvent -> m Bool
getAltKey self = liftDOM ((self ^. js "altKey") >>= valToBool)
getMetaKey :: (MonadDOM m) => KeyboardEvent -> m Bool
getMetaKey self = liftDOM ((self ^. js "metaKey") >>= valToBool)
getRepeat :: (MonadDOM m) => KeyboardEvent -> m Bool
getRepeat self = liftDOM ((self ^. js "repeat") >>= valToBool)
getIsComposing :: (MonadDOM m) => KeyboardEvent -> m Bool
getIsComposing self
= liftDOM ((self ^. js "isComposing") >>= valToBool)
getKeyIdentifier ::
(MonadDOM m, FromJSString result) => KeyboardEvent -> m result
getKeyIdentifier self
= liftDOM ((self ^. js "keyIdentifier") >>= fromJSValUnchecked)
getKeyLocation :: (MonadDOM m) => KeyboardEvent -> m Word
getKeyLocation self
= liftDOM (round <$> ((self ^. js "keyLocation") >>= valToNumber))
getAltGraphKey :: (MonadDOM m) => KeyboardEvent -> m Bool
getAltGraphKey self
= liftDOM ((self ^. js "altGraphKey") >>= valToBool)
getCharCode :: (MonadDOM m) => KeyboardEvent -> m Word
getCharCode self
= liftDOM (round <$> ((self ^. js "charCode") >>= valToNumber))
getKeyCode :: (MonadDOM m) => KeyboardEvent -> m Word
getKeyCode self
= liftDOM (round <$> ((self ^. js "keyCode") >>= valToNumber))
getWhich :: (MonadDOM m) => KeyboardEvent -> m Word
getWhich self
= liftDOM (round <$> ((self ^. js "which") >>= valToNumber))