packages feed

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

{-# LANGUAGE PatternSynonyms #-}
{-# LANGUAGE ImplicitParams, ConstraintKinds, KindSignatures #-}
{-# OPTIONS_GHC -fno-warn-unused-imports #-}
-- | Generated by dom-gen from touch-events (webref). Do not edit.
module JSDOM.Generated.TouchEventInit
       (newTouchEventInit, setTouches, getTouches, getTouchesUnsafe, getTouchesUnchecked, setTargetTouches, getTargetTouches, getTargetTouchesUnsafe, getTargetTouchesUnchecked, setChangedTouches, getChangedTouches, getChangedTouchesUnsafe, getChangedTouchesUnchecked, TouchEventInit(..), gTypeTouchEventInit)
       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/touch-events/#dom-toucheventinit TouchEventInit specification>
newTouchEventInit :: (MonadDOM m) => m TouchEventInit
newTouchEventInit = liftDOM ((((new (jsg "Object") () >>= \o -> P.return o)) >>= fromJSValUnchecked))

-- | <https://w3c.github.io/touch-events/#dom-toucheventinit-touches TouchEventInit.touches specification>
setTouches :: (MonadDOM m) => TouchEventInit -> [Touch] -> m ()
setTouches self val = liftDOM (void (self ^. jss "touches" (toJSVal val)))

-- | <https://w3c.github.io/touch-events/#dom-toucheventinit-touches TouchEventInit.touches specification>
getTouches :: (MonadDOM m) => TouchEventInit -> m (Maybe [Touch])
getTouches self = liftDOM (((self ^. js "touches") >>= fromJSValUnchecked))

-- | <https://w3c.github.io/touch-events/#dom-toucheventinit-touches TouchEventInit.touches specification>
getTouchesUnsafe :: (MonadDOM m, HasCallStack) => TouchEventInit -> m [Touch]
getTouchesUnsafe self = liftDOM ((((self ^. js "touches") >>= fromJSValUnchecked) >>= P.maybe (P.error "Nothing to return") P.return))

-- | <https://w3c.github.io/touch-events/#dom-toucheventinit-touches TouchEventInit.touches specification>
getTouchesUnchecked :: (MonadDOM m) => TouchEventInit -> m [Touch]
getTouchesUnchecked self = liftDOM (((self ^. js "touches") >>= fromJSValUnchecked))

-- | <https://w3c.github.io/touch-events/#dom-toucheventinit-targettouches TouchEventInit.targetTouches specification>
setTargetTouches :: (MonadDOM m) => TouchEventInit -> [Touch] -> m ()
setTargetTouches self val = liftDOM (void (self ^. jss "targetTouches" (toJSVal val)))

-- | <https://w3c.github.io/touch-events/#dom-toucheventinit-targettouches TouchEventInit.targetTouches specification>
getTargetTouches :: (MonadDOM m) => TouchEventInit -> m (Maybe [Touch])
getTargetTouches self = liftDOM (((self ^. js "targetTouches") >>= fromJSValUnchecked))

-- | <https://w3c.github.io/touch-events/#dom-toucheventinit-targettouches TouchEventInit.targetTouches specification>
getTargetTouchesUnsafe :: (MonadDOM m, HasCallStack) => TouchEventInit -> m [Touch]
getTargetTouchesUnsafe self = liftDOM ((((self ^. js "targetTouches") >>= fromJSValUnchecked) >>= P.maybe (P.error "Nothing to return") P.return))

-- | <https://w3c.github.io/touch-events/#dom-toucheventinit-targettouches TouchEventInit.targetTouches specification>
getTargetTouchesUnchecked :: (MonadDOM m) => TouchEventInit -> m [Touch]
getTargetTouchesUnchecked self = liftDOM (((self ^. js "targetTouches") >>= fromJSValUnchecked))

-- | <https://w3c.github.io/touch-events/#dom-toucheventinit-changedtouches TouchEventInit.changedTouches specification>
setChangedTouches :: (MonadDOM m) => TouchEventInit -> [Touch] -> m ()
setChangedTouches self val = liftDOM (void (self ^. jss "changedTouches" (toJSVal val)))

-- | <https://w3c.github.io/touch-events/#dom-toucheventinit-changedtouches TouchEventInit.changedTouches specification>
getChangedTouches :: (MonadDOM m) => TouchEventInit -> m (Maybe [Touch])
getChangedTouches self = liftDOM (((self ^. js "changedTouches") >>= fromJSValUnchecked))

-- | <https://w3c.github.io/touch-events/#dom-toucheventinit-changedtouches TouchEventInit.changedTouches specification>
getChangedTouchesUnsafe :: (MonadDOM m, HasCallStack) => TouchEventInit -> m [Touch]
getChangedTouchesUnsafe self = liftDOM ((((self ^. js "changedTouches") >>= fromJSValUnchecked) >>= P.maybe (P.error "Nothing to return") P.return))

-- | <https://w3c.github.io/touch-events/#dom-toucheventinit-changedtouches TouchEventInit.changedTouches specification>
getChangedTouchesUnchecked :: (MonadDOM m) => TouchEventInit -> m [Touch]
getChangedTouchesUnchecked self = liftDOM (((self ^. js "changedTouches") >>= fromJSValUnchecked))