module JSDOM.Generated.MouseEvent
(newMouseEvent, initMouseEvent, pattern WEBKIT_FORCE_AT_MOUSE_DOWN,
pattern WEBKIT_FORCE_AT_FORCE_MOUSE_DOWN, getScreenX, getScreenY,
getClientX, getClientY, getCtrlKey, getShiftKey, getAltKey,
getMetaKey, getButton, getRelatedTarget, getRelatedTargetUnsafe,
getRelatedTargetUnchecked, getMovementX, getMovementY,
getWebkitForce, getOffsetX, getOffsetY, getX, getY, getFromElement,
getFromElementUnsafe, getFromElementUnchecked, getToElement,
getToElementUnsafe, getToElementUnchecked, getDataTransfer,
getDataTransferUnsafe, getDataTransferUnchecked, MouseEvent(..),
gTypeMouseEvent, IsMouseEvent, toMouseEvent)
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
newMouseEvent ::
(MonadDOM m, ToJSString type', IsMouseEventInit eventInitDict) =>
type' -> Maybe eventInitDict -> m MouseEvent
newMouseEvent type' eventInitDict
= liftDOM
(MouseEvent <$>
new (jsg "MouseEvent") [toJSVal type', toJSVal eventInitDict])
initMouseEvent ::
(MonadDOM m, IsMouseEvent self, ToJSString type',
ToJSVal relatedTarget) =>
self ->
Maybe type' ->
Bool ->
Bool ->
Maybe Window ->
Maybe Int ->
Maybe Int ->
Maybe Int ->
Maybe Int ->
Maybe Int ->
Bool ->
Bool ->
Bool -> Bool -> Maybe Word -> Maybe relatedTarget -> m ()
initMouseEvent self type' canBubble cancelable view detail screenX
screenY clientX clientY ctrlKey altKey shiftKey metaKey button
relatedTarget
= liftDOM
(void
((toMouseEvent self) ^. jsf "initMouseEvent"
[toJSVal type', toJSVal canBubble, toJSVal cancelable,
toJSVal view, toJSVal detail, toJSVal screenX, toJSVal screenY,
toJSVal clientX, toJSVal clientY, toJSVal ctrlKey, toJSVal altKey,
toJSVal shiftKey, toJSVal metaKey, toJSVal button,
toJSVal relatedTarget]))
pattern WEBKIT_FORCE_AT_MOUSE_DOWN = 1
pattern WEBKIT_FORCE_AT_FORCE_MOUSE_DOWN = 2
getScreenX :: (MonadDOM m, IsMouseEvent self) => self -> m Int
getScreenX self
= liftDOM
(round <$> (((toMouseEvent self) ^. js "screenX") >>= valToNumber))
getScreenY :: (MonadDOM m, IsMouseEvent self) => self -> m Int
getScreenY self
= liftDOM
(round <$> (((toMouseEvent self) ^. js "screenY") >>= valToNumber))
getClientX :: (MonadDOM m, IsMouseEvent self) => self -> m Int
getClientX self
= liftDOM
(round <$> (((toMouseEvent self) ^. js "clientX") >>= valToNumber))
getClientY :: (MonadDOM m, IsMouseEvent self) => self -> m Int
getClientY self
= liftDOM
(round <$> (((toMouseEvent self) ^. js "clientY") >>= valToNumber))
getCtrlKey :: (MonadDOM m, IsMouseEvent self) => self -> m Bool
getCtrlKey self
= liftDOM (((toMouseEvent self) ^. js "ctrlKey") >>= valToBool)
getShiftKey :: (MonadDOM m, IsMouseEvent self) => self -> m Bool
getShiftKey self
= liftDOM (((toMouseEvent self) ^. js "shiftKey") >>= valToBool)
getAltKey :: (MonadDOM m, IsMouseEvent self) => self -> m Bool
getAltKey self
= liftDOM (((toMouseEvent self) ^. js "altKey") >>= valToBool)
getMetaKey :: (MonadDOM m, IsMouseEvent self) => self -> m Bool
getMetaKey self
= liftDOM (((toMouseEvent self) ^. js "metaKey") >>= valToBool)
getButton :: (MonadDOM m, IsMouseEvent self) => self -> m Word
getButton self
= liftDOM
(round <$> (((toMouseEvent self) ^. js "button") >>= valToNumber))
getRelatedTarget ::
(MonadDOM m, IsMouseEvent self) => self -> m (Maybe EventTarget)
getRelatedTarget self
= liftDOM
(((toMouseEvent self) ^. js "relatedTarget") >>= fromJSVal)
getRelatedTargetUnsafe ::
(MonadDOM m, IsMouseEvent self, HasCallStack) =>
self -> m EventTarget
getRelatedTargetUnsafe self
= liftDOM
((((toMouseEvent self) ^. js "relatedTarget") >>= fromJSVal) >>=
maybe (Prelude.error "Nothing to return") return)
getRelatedTargetUnchecked ::
(MonadDOM m, IsMouseEvent self) => self -> m EventTarget
getRelatedTargetUnchecked self
= liftDOM
(((toMouseEvent self) ^. js "relatedTarget") >>=
fromJSValUnchecked)
getMovementX :: (MonadDOM m, IsMouseEvent self) => self -> m Int
getMovementX self
= liftDOM
(round <$>
(((toMouseEvent self) ^. js "movementX") >>= valToNumber))
getMovementY :: (MonadDOM m, IsMouseEvent self) => self -> m Int
getMovementY self
= liftDOM
(round <$>
(((toMouseEvent self) ^. js "movementY") >>= valToNumber))
getWebkitForce ::
(MonadDOM m, IsMouseEvent self) => self -> m Double
getWebkitForce self
= liftDOM
(((toMouseEvent self) ^. js "webkitForce") >>= valToNumber)
getOffsetX :: (MonadDOM m, IsMouseEvent self) => self -> m Int
getOffsetX self
= liftDOM
(round <$> (((toMouseEvent self) ^. js "offsetX") >>= valToNumber))
getOffsetY :: (MonadDOM m, IsMouseEvent self) => self -> m Int
getOffsetY self
= liftDOM
(round <$> (((toMouseEvent self) ^. js "offsetY") >>= valToNumber))
getX :: (MonadDOM m, IsMouseEvent self) => self -> m Int
getX self
= liftDOM
(round <$> (((toMouseEvent self) ^. js "x") >>= valToNumber))
getY :: (MonadDOM m, IsMouseEvent self) => self -> m Int
getY self
= liftDOM
(round <$> (((toMouseEvent self) ^. js "y") >>= valToNumber))
getFromElement ::
(MonadDOM m, IsMouseEvent self) => self -> m (Maybe Node)
getFromElement self
= liftDOM (((toMouseEvent self) ^. js "fromElement") >>= fromJSVal)
getFromElementUnsafe ::
(MonadDOM m, IsMouseEvent self, HasCallStack) => self -> m Node
getFromElementUnsafe self
= liftDOM
((((toMouseEvent self) ^. js "fromElement") >>= fromJSVal) >>=
maybe (Prelude.error "Nothing to return") return)
getFromElementUnchecked ::
(MonadDOM m, IsMouseEvent self) => self -> m Node
getFromElementUnchecked self
= liftDOM
(((toMouseEvent self) ^. js "fromElement") >>= fromJSValUnchecked)
getToElement ::
(MonadDOM m, IsMouseEvent self) => self -> m (Maybe Node)
getToElement self
= liftDOM (((toMouseEvent self) ^. js "toElement") >>= fromJSVal)
getToElementUnsafe ::
(MonadDOM m, IsMouseEvent self, HasCallStack) => self -> m Node
getToElementUnsafe self
= liftDOM
((((toMouseEvent self) ^. js "toElement") >>= fromJSVal) >>=
maybe (Prelude.error "Nothing to return") return)
getToElementUnchecked ::
(MonadDOM m, IsMouseEvent self) => self -> m Node
getToElementUnchecked self
= liftDOM
(((toMouseEvent self) ^. js "toElement") >>= fromJSValUnchecked)
getDataTransfer ::
(MonadDOM m, IsMouseEvent self) => self -> m (Maybe DataTransfer)
getDataTransfer self
= liftDOM
(((toMouseEvent self) ^. js "dataTransfer") >>= fromJSVal)
getDataTransferUnsafe ::
(MonadDOM m, IsMouseEvent self, HasCallStack) =>
self -> m DataTransfer
getDataTransferUnsafe self
= liftDOM
((((toMouseEvent self) ^. js "dataTransfer") >>= fromJSVal) >>=
maybe (Prelude.error "Nothing to return") return)
getDataTransferUnchecked ::
(MonadDOM m, IsMouseEvent self) => self -> m DataTransfer
getDataTransferUnchecked self
= liftDOM
(((toMouseEvent self) ^. js "dataTransfer") >>= fromJSValUnchecked)