packages feed

ghcjs-dom-javascript-0.10.0.0: src/GHCJS/DOM/JSFFI/Generated/CommandEvent.hs

{-# LANGUAGE PatternSynonyms #-}
{-# LANGUAGE ForeignFunctionInterface, JavaScriptFFI #-}
{-# LANGUAGE ImplicitParams, ConstraintKinds, KindSignatures #-}
{-# OPTIONS_GHC -fno-warn-unused-imports #-}
-- | Generated by dom-gen from html (webref). Do not edit.
module GHCJS.DOM.JSFFI.Generated.CommandEvent
       (js_newCommandEvent, js_getSource, js_getCommand, newCommandEvent, getSource, getSourceUnsafe, getSourceUnchecked, getCommand, CommandEvent(..), gTypeCommandEvent)
       where
import Prelude ((.), (==), (>>=), (<$>), (++), Bool(..), Maybe(..), IO, Int, Word, Double, Float)
import qualified Prelude as P
import Control.Monad (void)
import GHCJS.Types (JSVal, JSString)
import GHCJS.Foreign (jsUndefined, jsNull)
import GHCJS.DOM.Types
import qualified GHCJS.DOM.Types as Types
import GHCJS.DOM.EventTargetClosures (EventName, unsafeEventName, unsafeEventNameAsync)
import GHCJS.DOM.JSFFI.Generated.Enums

foreign import javascript safe "(($1, $2) => { return new globalThis[\"CommandEvent\"]($1, $2); })"
        js_newCommandEvent :: JSString -> JSVal -> IO CommandEvent
-- | <https://developer.mozilla.org/docs/Web/API/CommandEvent/CommandEvent MDN CommandEvent. documentation>
newCommandEvent :: (MonadDOM m, ToJSString type') => type' -> Maybe CommandEventInit -> m CommandEvent
newCommandEvent type' eventInitDict = liftDOM (((P.maybe (P.return jsUndefined) toJSVal eventInitDict) >>= \a2' -> js_newCommandEvent (toJSString type') a2'))

foreign import javascript unsafe "(($1) => { return $1[\"source\"]; })"
        js_getSource :: CommandEvent -> IO JSVal
-- | <https://developer.mozilla.org/docs/Web/API/CommandEvent/source MDN CommandEvent.source documentation>
getSource :: (MonadDOM m) => CommandEvent -> m (Maybe Element)
getSource self = liftDOM (((js_getSource (self)) >>= fromJSValUnchecked))

-- | <https://developer.mozilla.org/docs/Web/API/CommandEvent/source MDN CommandEvent.source documentation>
getSourceUnsafe :: (MonadDOM m, HasCallStack) => CommandEvent -> m Element
getSourceUnsafe self = liftDOM ((((js_getSource (self)) >>= fromJSValUnchecked) >>= P.maybe (P.error "Nothing to return") P.return))

-- | <https://developer.mozilla.org/docs/Web/API/CommandEvent/source MDN CommandEvent.source documentation>
getSourceUnchecked :: (MonadDOM m) => CommandEvent -> m Element
getSourceUnchecked self = liftDOM ((pFromJSVal <$> (js_getSource (self))))

foreign import javascript unsafe "(($1) => { return $1[\"command\"]; })"
        js_getCommand :: CommandEvent -> IO JSString
-- | <https://developer.mozilla.org/docs/Web/API/CommandEvent/command MDN CommandEvent.command documentation>
getCommand :: (MonadDOM m, FromJSString result) => CommandEvent -> m result
getCommand self = liftDOM ((fromJSString <$> (js_getCommand (self))))