{-# LANGUAGE PatternSynonyms #-}
-- For HasCallStack compatibility
{-# LANGUAGE ImplicitParams, ConstraintKinds, KindSignatures #-}
{-# OPTIONS_GHC -fno-warn-unused-imports #-}
module JSDOM.Generated.UIEvent
       (newUIEvent, initUIEvent, getView, getDetail, getLayerX, getLayerY,
        getPageX, getPageY, getWhich, UIEvent(..), gTypeUIEvent, IsUIEvent,
        toUIEvent)
       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.Enums

-- | <https://developer.mozilla.org/en-US/docs/Web/API/UIEvent Mozilla UIEvent documentation> 
newUIEvent ::
           (MonadDOM m, ToJSString type', IsUIEventInit eventInitDict) =>
             type' -> Maybe eventInitDict -> m UIEvent
newUIEvent :: forall (m :: * -> *) type' eventInitDict.
(MonadDOM m, ToJSString type', IsUIEventInit eventInitDict) =>
type' -> Maybe eventInitDict -> m UIEvent
newUIEvent type'
type' Maybe eventInitDict
eventInitDict
  = DOM UIEvent -> m UIEvent
forall (m :: * -> *) a. MonadDOM m => DOM a -> m a
liftDOM
      (JSVal -> UIEvent
UIEvent (JSVal -> UIEvent) -> JSM JSVal -> DOM UIEvent
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$>
         JSM JSVal -> [JSM JSVal] -> JSM JSVal
forall constructor args.
(MakeObject constructor, MakeArgs args) =>
constructor -> args -> JSM JSVal
new (String -> JSM JSVal
forall a. ToJSString a => a -> JSM JSVal
jsg String
"UIEvent") [type' -> JSM JSVal
forall a. ToJSVal a => a -> JSM JSVal
toJSVal type'
type', Maybe eventInitDict -> JSM JSVal
forall a. ToJSVal a => a -> JSM JSVal
toJSVal Maybe eventInitDict
eventInitDict])

-- | <https://developer.mozilla.org/en-US/docs/Web/API/UIEvent.initUIEvent Mozilla UIEvent.initUIEvent documentation> 
initUIEvent ::
            (MonadDOM m, IsUIEvent self, ToJSString type') =>
              self ->
                Maybe type' -> Bool -> Bool -> Maybe Window -> Maybe Int -> m ()
initUIEvent :: forall (m :: * -> *) self type'.
(MonadDOM m, IsUIEvent self, ToJSString type') =>
self
-> Maybe type' -> Bool -> Bool -> Maybe Window -> Maybe Int -> m ()
initUIEvent self
self Maybe type'
type' Bool
canBubble Bool
cancelable Maybe Window
view Maybe Int
detail
  = DOM () -> m ()
forall (m :: * -> *) a. MonadDOM m => DOM a -> m a
liftDOM
      (JSM JSVal -> DOM ()
forall (f :: * -> *) a. Functor f => f a -> f ()
void
         ((self -> UIEvent
forall o. IsUIEvent o => o -> UIEvent
toUIEvent self
self) UIEvent -> Getting (JSM JSVal) UIEvent (JSM JSVal) -> JSM JSVal
forall s a. s -> Getting a s a -> a
^. String -> [JSM JSVal] -> JSF
forall name args.
(ToJSString name, MakeArgs args) =>
name -> args -> JSF
jsf String
"initUIEvent"
            [Maybe type' -> JSM JSVal
forall a. ToJSVal a => a -> JSM JSVal
toJSVal Maybe type'
type', Bool -> JSM JSVal
forall a. ToJSVal a => a -> JSM JSVal
toJSVal Bool
canBubble, Bool -> JSM JSVal
forall a. ToJSVal a => a -> JSM JSVal
toJSVal Bool
cancelable,
             Maybe Window -> JSM JSVal
forall a. ToJSVal a => a -> JSM JSVal
toJSVal Maybe Window
view, Maybe Int -> JSM JSVal
forall a. ToJSVal a => a -> JSM JSVal
toJSVal Maybe Int
detail]))

-- | <https://developer.mozilla.org/en-US/docs/Web/API/UIEvent.view Mozilla UIEvent.view documentation> 
getView :: (MonadDOM m, IsUIEvent self) => self -> m Window
getView :: forall (m :: * -> *) self.
(MonadDOM m, IsUIEvent self) =>
self -> m Window
getView self
self
  = DOM Window -> m Window
forall (m :: * -> *) a. MonadDOM m => DOM a -> m a
liftDOM (((self -> UIEvent
forall o. IsUIEvent o => o -> UIEvent
toUIEvent self
self) UIEvent -> Getting (JSM JSVal) UIEvent (JSM JSVal) -> JSM JSVal
forall s a. s -> Getting a s a -> a
^. String -> IndexPreservingGetter UIEvent (JSM JSVal)
forall s name.
(MakeObject s, ToJSString name) =>
name -> IndexPreservingGetter s (JSM JSVal)
js String
"view") JSM JSVal -> (JSVal -> DOM Window) -> DOM Window
forall a b. JSM a -> (a -> JSM b) -> JSM b
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= JSVal -> DOM Window
forall a. FromJSVal a => JSVal -> JSM a
fromJSValUnchecked)

-- | <https://developer.mozilla.org/en-US/docs/Web/API/UIEvent.detail Mozilla UIEvent.detail documentation> 
getDetail :: (MonadDOM m, IsUIEvent self) => self -> m Int
getDetail :: forall (m :: * -> *) self.
(MonadDOM m, IsUIEvent self) =>
self -> m Int
getDetail self
self
  = DOM Int -> m Int
forall (m :: * -> *) a. MonadDOM m => DOM a -> m a
liftDOM
      (Double -> Int
forall b. Integral b => Double -> b
forall a b. (RealFrac a, Integral b) => a -> b
round (Double -> Int) -> JSM Double -> DOM Int
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> (((self -> UIEvent
forall o. IsUIEvent o => o -> UIEvent
toUIEvent self
self) UIEvent -> Getting (JSM JSVal) UIEvent (JSM JSVal) -> JSM JSVal
forall s a. s -> Getting a s a -> a
^. String -> IndexPreservingGetter UIEvent (JSM JSVal)
forall s name.
(MakeObject s, ToJSString name) =>
name -> IndexPreservingGetter s (JSM JSVal)
js String
"detail") JSM JSVal -> (JSVal -> JSM Double) -> JSM Double
forall a b. JSM a -> (a -> JSM b) -> JSM b
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= JSVal -> JSM Double
forall value. ToJSVal value => value -> JSM Double
valToNumber))

-- | <https://developer.mozilla.org/en-US/docs/Web/API/UIEvent.layerX Mozilla UIEvent.layerX documentation> 
getLayerX :: (MonadDOM m, IsUIEvent self) => self -> m Int
getLayerX :: forall (m :: * -> *) self.
(MonadDOM m, IsUIEvent self) =>
self -> m Int
getLayerX self
self
  = DOM Int -> m Int
forall (m :: * -> *) a. MonadDOM m => DOM a -> m a
liftDOM
      (Double -> Int
forall b. Integral b => Double -> b
forall a b. (RealFrac a, Integral b) => a -> b
round (Double -> Int) -> JSM Double -> DOM Int
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> (((self -> UIEvent
forall o. IsUIEvent o => o -> UIEvent
toUIEvent self
self) UIEvent -> Getting (JSM JSVal) UIEvent (JSM JSVal) -> JSM JSVal
forall s a. s -> Getting a s a -> a
^. String -> IndexPreservingGetter UIEvent (JSM JSVal)
forall s name.
(MakeObject s, ToJSString name) =>
name -> IndexPreservingGetter s (JSM JSVal)
js String
"layerX") JSM JSVal -> (JSVal -> JSM Double) -> JSM Double
forall a b. JSM a -> (a -> JSM b) -> JSM b
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= JSVal -> JSM Double
forall value. ToJSVal value => value -> JSM Double
valToNumber))

-- | <https://developer.mozilla.org/en-US/docs/Web/API/UIEvent.layerY Mozilla UIEvent.layerY documentation> 
getLayerY :: (MonadDOM m, IsUIEvent self) => self -> m Int
getLayerY :: forall (m :: * -> *) self.
(MonadDOM m, IsUIEvent self) =>
self -> m Int
getLayerY self
self
  = DOM Int -> m Int
forall (m :: * -> *) a. MonadDOM m => DOM a -> m a
liftDOM
      (Double -> Int
forall b. Integral b => Double -> b
forall a b. (RealFrac a, Integral b) => a -> b
round (Double -> Int) -> JSM Double -> DOM Int
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> (((self -> UIEvent
forall o. IsUIEvent o => o -> UIEvent
toUIEvent self
self) UIEvent -> Getting (JSM JSVal) UIEvent (JSM JSVal) -> JSM JSVal
forall s a. s -> Getting a s a -> a
^. String -> IndexPreservingGetter UIEvent (JSM JSVal)
forall s name.
(MakeObject s, ToJSString name) =>
name -> IndexPreservingGetter s (JSM JSVal)
js String
"layerY") JSM JSVal -> (JSVal -> JSM Double) -> JSM Double
forall a b. JSM a -> (a -> JSM b) -> JSM b
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= JSVal -> JSM Double
forall value. ToJSVal value => value -> JSM Double
valToNumber))

-- | <https://developer.mozilla.org/en-US/docs/Web/API/UIEvent.pageX Mozilla UIEvent.pageX documentation> 
getPageX :: (MonadDOM m, IsUIEvent self) => self -> m Int
getPageX :: forall (m :: * -> *) self.
(MonadDOM m, IsUIEvent self) =>
self -> m Int
getPageX self
self
  = DOM Int -> m Int
forall (m :: * -> *) a. MonadDOM m => DOM a -> m a
liftDOM
      (Double -> Int
forall b. Integral b => Double -> b
forall a b. (RealFrac a, Integral b) => a -> b
round (Double -> Int) -> JSM Double -> DOM Int
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> (((self -> UIEvent
forall o. IsUIEvent o => o -> UIEvent
toUIEvent self
self) UIEvent -> Getting (JSM JSVal) UIEvent (JSM JSVal) -> JSM JSVal
forall s a. s -> Getting a s a -> a
^. String -> IndexPreservingGetter UIEvent (JSM JSVal)
forall s name.
(MakeObject s, ToJSString name) =>
name -> IndexPreservingGetter s (JSM JSVal)
js String
"pageX") JSM JSVal -> (JSVal -> JSM Double) -> JSM Double
forall a b. JSM a -> (a -> JSM b) -> JSM b
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= JSVal -> JSM Double
forall value. ToJSVal value => value -> JSM Double
valToNumber))

-- | <https://developer.mozilla.org/en-US/docs/Web/API/UIEvent.pageY Mozilla UIEvent.pageY documentation> 
getPageY :: (MonadDOM m, IsUIEvent self) => self -> m Int
getPageY :: forall (m :: * -> *) self.
(MonadDOM m, IsUIEvent self) =>
self -> m Int
getPageY self
self
  = DOM Int -> m Int
forall (m :: * -> *) a. MonadDOM m => DOM a -> m a
liftDOM
      (Double -> Int
forall b. Integral b => Double -> b
forall a b. (RealFrac a, Integral b) => a -> b
round (Double -> Int) -> JSM Double -> DOM Int
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> (((self -> UIEvent
forall o. IsUIEvent o => o -> UIEvent
toUIEvent self
self) UIEvent -> Getting (JSM JSVal) UIEvent (JSM JSVal) -> JSM JSVal
forall s a. s -> Getting a s a -> a
^. String -> IndexPreservingGetter UIEvent (JSM JSVal)
forall s name.
(MakeObject s, ToJSString name) =>
name -> IndexPreservingGetter s (JSM JSVal)
js String
"pageY") JSM JSVal -> (JSVal -> JSM Double) -> JSM Double
forall a b. JSM a -> (a -> JSM b) -> JSM b
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= JSVal -> JSM Double
forall value. ToJSVal value => value -> JSM Double
valToNumber))

-- | <https://developer.mozilla.org/en-US/docs/Web/API/UIEvent.which Mozilla UIEvent.which documentation> 
getWhich :: (MonadDOM m, IsUIEvent self) => self -> m Int
getWhich :: forall (m :: * -> *) self.
(MonadDOM m, IsUIEvent self) =>
self -> m Int
getWhich self
self
  = DOM Int -> m Int
forall (m :: * -> *) a. MonadDOM m => DOM a -> m a
liftDOM
      (Double -> Int
forall b. Integral b => Double -> b
forall a b. (RealFrac a, Integral b) => a -> b
round (Double -> Int) -> JSM Double -> DOM Int
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> (((self -> UIEvent
forall o. IsUIEvent o => o -> UIEvent
toUIEvent self
self) UIEvent -> Getting (JSM JSVal) UIEvent (JSM JSVal) -> JSM JSVal
forall s a. s -> Getting a s a -> a
^. String -> IndexPreservingGetter UIEvent (JSM JSVal)
forall s name.
(MakeObject s, ToJSString name) =>
name -> IndexPreservingGetter s (JSM JSVal)
js String
"which") JSM JSVal -> (JSVal -> JSM Double) -> JSM Double
forall a b. JSM a -> (a -> JSM b) -> JSM b
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= JSVal -> JSM Double
forall value. ToJSVal value => value -> JSM Double
valToNumber))