gi-gdk-0.3.18.13: GI/Gdk/Structs/EventKey.hs
{- |
Copyright : Will Thompson, Iñaki García Etxebarria and Jonas Platte
License : LGPL-2.1
Maintainer : Iñaki García Etxebarria (garetxe@gmail.com)
Describes a key press or key release event.
-}
module GI.Gdk.Structs.EventKey
(
-- * Exported types
EventKey(..) ,
newZeroEventKey ,
noEventKey ,
-- * Properties
-- ** Group
eventKeyReadGroup ,
-- ** HardwareKeycode
eventKeyReadHardwareKeycode ,
-- ** IsModifier
eventKeyReadIsModifier ,
-- ** Keyval
eventKeyReadKeyval ,
-- ** Length
eventKeyReadLength ,
-- ** SendEvent
eventKeyReadSendEvent ,
-- ** State
eventKeyReadState ,
-- ** String
eventKeyReadString ,
-- ** Time
eventKeyReadTime ,
-- ** Type
eventKeyReadType ,
-- ** Window
eventKeyReadWindow ,
) where
import Prelude ()
import Data.GI.Base.ShortPrelude
import qualified Data.Text as T
import qualified Data.ByteString.Char8 as B
import qualified Data.Map as Map
import GI.Gdk.Types
import GI.Gdk.Callbacks
newtype EventKey = EventKey (ForeignPtr EventKey)
-- | Construct a `EventKey` struct initialized to zero.
newZeroEventKey :: MonadIO m => m EventKey
newZeroEventKey = liftIO $ callocBytes 56 >>= wrapPtr EventKey
noEventKey :: Maybe EventKey
noEventKey = Nothing
eventKeyReadType :: EventKey -> IO EventType
eventKeyReadType s = withManagedPtr s $ \ptr -> do
val <- peek (ptr `plusPtr` 0) :: IO CUInt
let val' = (toEnum . fromIntegral) val
return val'
eventKeyReadWindow :: EventKey -> IO Window
eventKeyReadWindow s = withManagedPtr s $ \ptr -> do
val <- peek (ptr `plusPtr` 8) :: IO (Ptr Window)
val' <- (newObject Window) val
return val'
eventKeyReadSendEvent :: EventKey -> IO Int8
eventKeyReadSendEvent s = withManagedPtr s $ \ptr -> do
val <- peek (ptr `plusPtr` 16) :: IO Int8
return val
eventKeyReadTime :: EventKey -> IO Word32
eventKeyReadTime s = withManagedPtr s $ \ptr -> do
val <- peek (ptr `plusPtr` 20) :: IO Word32
return val
eventKeyReadState :: EventKey -> IO [ModifierType]
eventKeyReadState s = withManagedPtr s $ \ptr -> do
val <- peek (ptr `plusPtr` 24) :: IO CUInt
let val' = wordToGFlags val
return val'
eventKeyReadKeyval :: EventKey -> IO Word32
eventKeyReadKeyval s = withManagedPtr s $ \ptr -> do
val <- peek (ptr `plusPtr` 28) :: IO Word32
return val
eventKeyReadLength :: EventKey -> IO Int32
eventKeyReadLength s = withManagedPtr s $ \ptr -> do
val <- peek (ptr `plusPtr` 32) :: IO Int32
return val
eventKeyReadString :: EventKey -> IO T.Text
eventKeyReadString s = withManagedPtr s $ \ptr -> do
val <- peek (ptr `plusPtr` 40) :: IO CString
val' <- cstringToText val
return val'
eventKeyReadHardwareKeycode :: EventKey -> IO Word16
eventKeyReadHardwareKeycode s = withManagedPtr s $ \ptr -> do
val <- peek (ptr `plusPtr` 48) :: IO Word16
return val
eventKeyReadGroup :: EventKey -> IO Word8
eventKeyReadGroup s = withManagedPtr s $ \ptr -> do
val <- peek (ptr `plusPtr` 50) :: IO Word8
return val
eventKeyReadIsModifier :: EventKey -> IO Word32
eventKeyReadIsModifier s = withManagedPtr s $ \ptr -> do
val <- peek (ptr `plusPtr` 52) :: IO Word32
return val
type family ResolveEventKeyMethod (t :: Symbol) (o :: *) :: * where
ResolveEventKeyMethod l o = MethodResolutionFailed l o
instance (info ~ ResolveEventKeyMethod t EventKey, MethodInfo info EventKey p) => IsLabelProxy t (EventKey -> p) where
fromLabelProxy _ = overloadedMethod (MethodProxy :: MethodProxy info)
#if MIN_VERSION_base(4,9,0)
instance (info ~ ResolveEventKeyMethod t EventKey, MethodInfo info EventKey p) => IsLabel t (EventKey -> p) where
fromLabel _ = overloadedMethod (MethodProxy :: MethodProxy info)
#endif