packages feed

jsaddle-dom-0.10.0.0: src/JSDOM/Generated/KeyboardEventInit.hs

{-# LANGUAGE PatternSynonyms #-}
{-# LANGUAGE ImplicitParams, ConstraintKinds, KindSignatures #-}
{-# OPTIONS_GHC -fno-warn-unused-imports #-}
-- | Generated by dom-gen from uievents (webref). Do not edit.
module JSDOM.Generated.KeyboardEventInit
       (newKeyboardEventInit, setKey, getKey, getKeyUnsafe, getKeyUnchecked, setCode, getCode, getCodeUnsafe, getCodeUnchecked, setLocation, getLocation, getLocationUnsafe, getLocationUnchecked, setRepeat, getRepeat, getRepeatUnsafe, getRepeatUnchecked, setIsComposing, getIsComposing, getIsComposingUnsafe, getIsComposingUnchecked, setCharCode, getCharCode, getCharCodeUnsafe, getCharCodeUnchecked, setKeyCode, getKeyCode, getKeyCodeUnsafe, getKeyCodeUnchecked, KeyboardEventInit(..), gTypeKeyboardEventInit)
       where
import Prelude ((.), (==), (>>=), (<$>), (++), Bool(..), Maybe(..), IO, Int, Word, Double, Float)
import qualified Prelude as P
import Control.Monad (void)
import Control.Lens.Operators ((^.))
import Language.Javascript.JSaddle (JSM, JSVal, JSString, toJSVal, valToBool, valToNumber, js, jss, jsf, jsg, new, function, asyncFunction, jsUndefined, jsNull)
import JSDOM.Types
import qualified JSDOM.Types as Types
import JSDOM.EventTargetClosures (EventName, unsafeEventName, unsafeEventNameAsync)
import JSDOM.Generated.Enums

-- | <https://w3c.github.io/uievents/#dictdef-keyboardeventinit KeyboardEventInit specification>
newKeyboardEventInit :: (MonadDOM m) => m KeyboardEventInit
newKeyboardEventInit = liftDOM ((((new (jsg "Object") () >>= \o -> P.return o)) >>= fromJSValUnchecked))

-- | <https://w3c.github.io/uievents/#dom-keyboardeventinit-key KeyboardEventInit.key specification>
setKey :: (MonadDOM m, ToJSString val) => KeyboardEventInit -> val -> m ()
setKey self val = liftDOM (void (self ^. jss "key" (toJSVal val)))

-- | <https://w3c.github.io/uievents/#dom-keyboardeventinit-key KeyboardEventInit.key specification>
getKey :: (MonadDOM m, FromJSString result) => KeyboardEventInit -> m (Maybe result)
getKey self = liftDOM (((self ^. js "key") >>= fromMaybeJSString))

-- | <https://w3c.github.io/uievents/#dom-keyboardeventinit-key KeyboardEventInit.key specification>
getKeyUnsafe :: (MonadDOM m, HasCallStack, FromJSString result) => KeyboardEventInit -> m result
getKeyUnsafe self = liftDOM ((((self ^. js "key") >>= fromMaybeJSString) >>= P.maybe (P.error "Nothing to return") P.return))

-- | <https://w3c.github.io/uievents/#dom-keyboardeventinit-key KeyboardEventInit.key specification>
getKeyUnchecked :: (MonadDOM m, FromJSString result) => KeyboardEventInit -> m result
getKeyUnchecked self = liftDOM (((self ^. js "key") >>= fromJSValUnchecked))

-- | <https://w3c.github.io/uievents/#dom-keyboardeventinit-code KeyboardEventInit.code specification>
setCode :: (MonadDOM m, ToJSString val) => KeyboardEventInit -> val -> m ()
setCode self val = liftDOM (void (self ^. jss "code" (toJSVal val)))

-- | <https://w3c.github.io/uievents/#dom-keyboardeventinit-code KeyboardEventInit.code specification>
getCode :: (MonadDOM m, FromJSString result) => KeyboardEventInit -> m (Maybe result)
getCode self = liftDOM (((self ^. js "code") >>= fromMaybeJSString))

-- | <https://w3c.github.io/uievents/#dom-keyboardeventinit-code KeyboardEventInit.code specification>
getCodeUnsafe :: (MonadDOM m, HasCallStack, FromJSString result) => KeyboardEventInit -> m result
getCodeUnsafe self = liftDOM ((((self ^. js "code") >>= fromMaybeJSString) >>= P.maybe (P.error "Nothing to return") P.return))

-- | <https://w3c.github.io/uievents/#dom-keyboardeventinit-code KeyboardEventInit.code specification>
getCodeUnchecked :: (MonadDOM m, FromJSString result) => KeyboardEventInit -> m result
getCodeUnchecked self = liftDOM (((self ^. js "code") >>= fromJSValUnchecked))

-- | <https://w3c.github.io/uievents/#dom-keyboardeventinit-location KeyboardEventInit.location specification>
setLocation :: (MonadDOM m) => KeyboardEventInit -> Word -> m ()
setLocation self val = liftDOM (void (self ^. jss "location" (toJSVal val)))

-- | <https://w3c.github.io/uievents/#dom-keyboardeventinit-location KeyboardEventInit.location specification>
getLocation :: (MonadDOM m) => KeyboardEventInit -> m (Maybe Word)
getLocation self = liftDOM (((self ^. js "location") >>= fromJSValUnchecked))

-- | <https://w3c.github.io/uievents/#dom-keyboardeventinit-location KeyboardEventInit.location specification>
getLocationUnsafe :: (MonadDOM m, HasCallStack) => KeyboardEventInit -> m Word
getLocationUnsafe self = liftDOM ((((self ^. js "location") >>= fromJSValUnchecked) >>= P.maybe (P.error "Nothing to return") P.return))

-- | <https://w3c.github.io/uievents/#dom-keyboardeventinit-location KeyboardEventInit.location specification>
getLocationUnchecked :: (MonadDOM m) => KeyboardEventInit -> m Word
getLocationUnchecked self = liftDOM ((P.round <$> ((self ^. js "location") >>= valToNumber)))

-- | <https://w3c.github.io/uievents/#dom-keyboardeventinit-repeat KeyboardEventInit.repeat specification>
setRepeat :: (MonadDOM m) => KeyboardEventInit -> Bool -> m ()
setRepeat self val = liftDOM (void (self ^. jss "repeat" (toJSVal val)))

-- | <https://w3c.github.io/uievents/#dom-keyboardeventinit-repeat KeyboardEventInit.repeat specification>
getRepeat :: (MonadDOM m) => KeyboardEventInit -> m (Maybe Bool)
getRepeat self = liftDOM (((self ^. js "repeat") >>= fromJSValUnchecked))

-- | <https://w3c.github.io/uievents/#dom-keyboardeventinit-repeat KeyboardEventInit.repeat specification>
getRepeatUnsafe :: (MonadDOM m, HasCallStack) => KeyboardEventInit -> m Bool
getRepeatUnsafe self = liftDOM ((((self ^. js "repeat") >>= fromJSValUnchecked) >>= P.maybe (P.error "Nothing to return") P.return))

-- | <https://w3c.github.io/uievents/#dom-keyboardeventinit-repeat KeyboardEventInit.repeat specification>
getRepeatUnchecked :: (MonadDOM m) => KeyboardEventInit -> m Bool
getRepeatUnchecked self = liftDOM (((self ^. js "repeat") >>= valToBool))

-- | <https://w3c.github.io/uievents/#dom-keyboardeventinit-iscomposing KeyboardEventInit.isComposing specification>
setIsComposing :: (MonadDOM m) => KeyboardEventInit -> Bool -> m ()
setIsComposing self val = liftDOM (void (self ^. jss "isComposing" (toJSVal val)))

-- | <https://w3c.github.io/uievents/#dom-keyboardeventinit-iscomposing KeyboardEventInit.isComposing specification>
getIsComposing :: (MonadDOM m) => KeyboardEventInit -> m (Maybe Bool)
getIsComposing self = liftDOM (((self ^. js "isComposing") >>= fromJSValUnchecked))

-- | <https://w3c.github.io/uievents/#dom-keyboardeventinit-iscomposing KeyboardEventInit.isComposing specification>
getIsComposingUnsafe :: (MonadDOM m, HasCallStack) => KeyboardEventInit -> m Bool
getIsComposingUnsafe self = liftDOM ((((self ^. js "isComposing") >>= fromJSValUnchecked) >>= P.maybe (P.error "Nothing to return") P.return))

-- | <https://w3c.github.io/uievents/#dom-keyboardeventinit-iscomposing KeyboardEventInit.isComposing specification>
getIsComposingUnchecked :: (MonadDOM m) => KeyboardEventInit -> m Bool
getIsComposingUnchecked self = liftDOM (((self ^. js "isComposing") >>= valToBool))

-- | <https://w3c.github.io/uievents/#dom-keyboardeventinit-charcode KeyboardEventInit.charCode specification>
setCharCode :: (MonadDOM m) => KeyboardEventInit -> Word -> m ()
setCharCode self val = liftDOM (void (self ^. jss "charCode" (toJSVal val)))

-- | <https://w3c.github.io/uievents/#dom-keyboardeventinit-charcode KeyboardEventInit.charCode specification>
getCharCode :: (MonadDOM m) => KeyboardEventInit -> m (Maybe Word)
getCharCode self = liftDOM (((self ^. js "charCode") >>= fromJSValUnchecked))

-- | <https://w3c.github.io/uievents/#dom-keyboardeventinit-charcode KeyboardEventInit.charCode specification>
getCharCodeUnsafe :: (MonadDOM m, HasCallStack) => KeyboardEventInit -> m Word
getCharCodeUnsafe self = liftDOM ((((self ^. js "charCode") >>= fromJSValUnchecked) >>= P.maybe (P.error "Nothing to return") P.return))

-- | <https://w3c.github.io/uievents/#dom-keyboardeventinit-charcode KeyboardEventInit.charCode specification>
getCharCodeUnchecked :: (MonadDOM m) => KeyboardEventInit -> m Word
getCharCodeUnchecked self = liftDOM ((P.round <$> ((self ^. js "charCode") >>= valToNumber)))

-- | <https://w3c.github.io/uievents/#dom-keyboardeventinit-keycode KeyboardEventInit.keyCode specification>
setKeyCode :: (MonadDOM m) => KeyboardEventInit -> Word -> m ()
setKeyCode self val = liftDOM (void (self ^. jss "keyCode" (toJSVal val)))

-- | <https://w3c.github.io/uievents/#dom-keyboardeventinit-keycode KeyboardEventInit.keyCode specification>
getKeyCode :: (MonadDOM m) => KeyboardEventInit -> m (Maybe Word)
getKeyCode self = liftDOM (((self ^. js "keyCode") >>= fromJSValUnchecked))

-- | <https://w3c.github.io/uievents/#dom-keyboardeventinit-keycode KeyboardEventInit.keyCode specification>
getKeyCodeUnsafe :: (MonadDOM m, HasCallStack) => KeyboardEventInit -> m Word
getKeyCodeUnsafe self = liftDOM ((((self ^. js "keyCode") >>= fromJSValUnchecked) >>= P.maybe (P.error "Nothing to return") P.return))

-- | <https://w3c.github.io/uievents/#dom-keyboardeventinit-keycode KeyboardEventInit.keyCode specification>
getKeyCodeUnchecked :: (MonadDOM m) => KeyboardEventInit -> m Word
getKeyCodeUnchecked self = liftDOM ((P.round <$> ((self ^. js "keyCode") >>= valToNumber)))