BlitzMax

BlitzMax

  • Downloads
  • Docs
  • API
  • Resources
  • About

›Event

BlitzMax API

  • Introduction

BRL

    Audio

    • Introduction
    • TChannel
    • TSound

    AudioSample

    • Introduction
    • TAudioSample
    • TAudioSampleLoader

    Bank

    • Introduction
    • TBank

    BankStream

    • Introduction
    • TBankStream

    Base64

    • Introduction
    • TBase64

    Blitz

    • Introduction
    • TArrayBoundsException
    • TBlitzException
    • TNullFunctionException
    • TNullMethodException
    • TNullObjectException
    • TOutOfDataException
    • TRuntimeException
  • BRL.BMPLoader
  • Clipboard

    • Introduction
    • TClipboard
    • TClipboardOpts
    • TWin32ClipboardOpts
    • TX11ClipboardOpts
  • BRL.D3D7Max2D
  • BRL.D3D9Max2D
  • BRL.DirectSoundAudio
  • BRL.EndianStream
  • Event

    • Introduction
    • TEvent
  • BRL.EventQueue
  • BRL.FileSystem
  • BRL.FreeAudioAudio
  • BRL.GLGraphics
  • BRL.GLMax2D
  • BRL.GNet
  • BRL.Graphics
  • BRL.Hook
  • BRL.JPGLoader
  • BRL.KeyCodes
  • LinkedList

    • Introduction
    • TList
    • TListEnum
    • TLink

    Map

    • Introduction
    • TMap
    • TIntMap
    • TIntKey
    • TPtrMap
    • TPtrKey
    • TStringMap
  • BRL.Math
  • Matrix

    • Introduction
    • SMat2D
    • SMat2F
    • SMat2I
    • SMat3D
    • SMat3F
    • SMat3I
    • SMat4D
    • SMat4F
    • SMat4I

    Max2D

    • Introduction
    • TImage

    MaxLua

    • Introduction
    • TLuaClass
    • TLuaObject
  • BRL.OGGLoader
  • BRL.OpenALAudio
  • ObjectList

    • Introduction
    • TObjectList
    • TObjectListEnumerator
    • TObjectListReverseEnumerator

    Pixmap

    • Introduction
    • TPixmap
    • TPixmapLoader
  • BRL.PNGLoader
  • BRL.PolledInput
  • Quaternion

    • Introduction
    • SQuatD
    • SQuatF
    • SQuatI
  • BRL.RamStream
  • Random

    • Introduction
    • TRandom

    Reflection

    • Introduction
    • TTypeId
    • TMember
    • TConstant
    • TField
    • TGlobal
    • TFunction
    • TMethod
  • BRL.Retro
  • BRL.Socket
  • BRL.SocketStream
  • BRL.StandardIO
  • Stream

    • Introduction
    • TCStream
    • TIO
    • TStream
    • TStreamException
    • TStreamFactory
    • TStreamReadException
    • TStreamWrapper
    • TStreamWriteException

    StringBuilder

    • Introduction
    • TStringBuilder
    • TSplitBuffer
  • BRL.System
  • BRL.SystemDefault
  • BRL.TextStream
  • BRL.TGALoader
  • ThreadPool

    • Introduction
    • TRunnable
    • TThreadPoolExecutor

    Threads

    • Introduction
    • TThread
    • TThreadData
    • TMutex
    • TSemaphore
    • TCondVar

    Timer

    • Introduction
    • TChrono
  • BRL.TimerDefault
  • Vector

    • Introduction
    • SVec2D
    • SVec2F
    • SVec2I
    • SVec3D
    • SVec3F
    • SVec3I

    Volumes

    • Introduction
    • TVolume
  • BRL.WAVLoader

Text

    Format

    • Introduction
    • TFormatter

    JConv

    • Introduction
    • TJConv
    • TJConvBuilder
    • TJConvSerializer

    Json

    • Introduction
    • TJSON
    • TJSONObject
    • TJSONString
    • TJSONInteger
    • TJSONReal
    • TJSONBool
    • TJSONArray
    • TJSONNull
    • TJSONError
    • TJSONNumber

    Regex

    • Introduction
    • TRegEx
    • TRegExMatch
    • TRegExOptions
    • TRegExException

    Xml

    • Introduction
    • TxmlDoc
    • TxmlNode
    • TxmlAttribute

MaxGUI

  • MaxGUI.MaxGUI
  • MaxGUI.Drivers
  • MaxGUI.Localization
  • MaxGUI.ProxyGadgets
  • MaxGUI.CocoaMaxGUI
  • MaxGUI.Win32MaxGUIEx

PUB

  • Pub.FreeJoy
  • Pub.FreeProcess
  • Pub.Glad
  • Pub.Glew
  • Joystick

    • Introduction
    • TJoystickDriver
  • Pub.Lua
  • Pub.OpenAL
  • Pub.OpenGLES
  • Pub.xmmintrin
  • Pub.ZLib

Crypto

    Digest

    • Introduction
    • TMessageDigest
    • TDigestRegister
    • TNoSuchAlgorithmException

    Cipher

    • Introduction
    • TCipher
    • TCipherMode
    • Crypto.AESCipher
    • Crypto.AnubisCipher
    • Crypto.BlowfishCipher
    • Crypto.CamelliaCipher
    • Crypto.Cast5Cipher
    • Crypto.DESCipher
    • Crypto.IdeaCipher
    • Crypto.KasumiCipher
    • Crypto.KhazadCipher
    • Crypto.KSeedCipher
    • Crypto.NoekeonCipher
    • Crypto.SerpentCipher
    • Crypto.SkipjackCipher
    • Crypto.TwofishCipher
    • Crypto.XTeaCipher

    CBCMode

    • Introduction
    • TCBCCipherMode

    CFBMode

    • Introduction
    • TCFBCipherMode

    CTRMode

    • Introduction
    • TCTRCipherMode

    ECBMode

    • Introduction
    • TECBCipherMode

    F8Mode

    • Introduction
    • TF8CipherMode

    LRWMode

    • Introduction
    • TLRWCipherMode

    OFBMode

    • Introduction
    • TOFBCipherMode

    XTSMode

    • Introduction
    • TXTSCipherMode

    Blake2BDigest

    • Introduction
    • TBlake2B_512
    • TBlake2B_384
    • TBlake2B_256
    • TBlake2B_160

    CRC32

    • Introduction
    • TCRC32

    MD5Digest

    • Introduction
    • TMD5

    Ripemd320Digest

    • Introduction
    • TRipemd320

    Ripemd356Digest

    • Introduction
    • TRipemd256

    Ripemd160Digest

    • Introduction
    • TRipemd160

    Ripemd128Digest

    • Introduction
    • TRipemd128

    SHA1Digest

    • Introduction
    • TSHA1

    SHA256Digest

    • Introduction
    • TSHA256

    SHA512Digest

    • Introduction
    • TSHA512

    SHA3Digest

    • Introduction
    • TSHA3_512
    • TSHA3_384
    • TSHA3_256
    • TSHA3_224

    TigerDigest

    • Introduction
    • TTiger

    WhirlpoolDigest

    • Introduction
    • TWhirlpool

    Crypto

    • Introduction
    • TCryptoRandom
    • TCryptoSecretBox
    • TCryptoHash
    • TCryptoSign
    • TCryptoKeyExchange
    • TCryptoKey
    • TCryptoHashKey
    • TCryptoSecretBoxKey
    • TCryptoSignature
    • TCryptoExchangeKeyPair
    • TCryptoSessionKeyPair
    • TCryptoNPacket
    • TCryptoKK1Packet
    • TCryptoKK2Packet
    • TCryptoXX1Packet
    • TCryptoXX2Packet
    • TCryptoXX3Packet
    • TCryptoExchangeState
    • TCryptoPWHashMasterKey
    • TCryptoPWHashStoredKey
    • TCryptoPasswordHash

SDL

    SDL

    • Introduction
    • TSDLStream

    SDLSystem

    • Introduction
    • TSDLMultiGesture

    SDLVideo

    • Introduction
    • TSDLDisplay
    • TSDLDisplayMode
    • TSDLGLContext
    • TSDLWindow

    SDLRender

    • Introduction
    • TSDLRenderer
    • TSDLTexture

    SDLTimer

    • Introduction
    • TSDLTimer

    SDLHaptic

    • Introduction
    • TSDLHaptic
    • TSDLHapticCondition
    • TSDLHapticConstant
    • TSDLHapticCustom
    • TSDLHapticDirection
    • TSDLHapticEffect
    • TSDLHapticLeftRight
    • TSDLHapticPeriodic
    • TSDLHapticRamp

    SDLSensor

    • Introduction
    • TSDLSensor
  • SDL.SDLFreeAudio
  • SDL.GLSDLMax2D
  • SDL.GL2SDLMax2D
  • SDL.D3D9SDLMax2D
  • SDLVirtualJoystick

    • Introduction
    • TVirtualJoystick

Steam

    SteamSDK

    • Introduction
    • TSteamClient
    • TSteamUtils
    • TSteamUserStats
    • TSteamFriends
    • TSteamUGC
    • ISteamFriendsListener
    • ISteamUGCListener
    • ISteamUserStatsListener
    • ISteamUtilsListener
    • EItemPreviewType
    • EPersonaChange
    • EPersonaState
    • ERemoteStoragePublishedFileVisibility
    • EUGCMatchingUGCType
    • EUGCQuery
    • EUserRestriction
    • EUserUGCList
    • EWorkshopFileType
Edit

BRL.Event

Event objects are used to notify your application about external events such as user input, user interface activity and so on.

The are two main ways your program can receive events: either by adding a hook function to the EmitEventHook hook, or by using using the global event queue

The most important field in an event object is the id field, which identifies the kind of event:

Event idDescription
EVENT_APPSUSPENDApplication suspended
EVENT_APPRESUMEApplication resumed
EVENT_APPTERMINATEApplication wants to terminate
EVENT_KEYDOWNKey pressed. Event data contains keycode
EVENT_KEYUPKey released. Event data contains keycode
EVENT_KEYCHARKey character being pressed. Event data contains unicode value of character.
EVENT_KEYREPEATKey held down. Event data contains keycode
EVENT_MOUSEDOWNMouse button pressed. Event data contains mouse button code
EVENT_MOUSEUPMouse button released. Event data contains mouse button code
EVENT_MOUSEMOVEMouse moved. Event x and y contain mouse coordinates
EVENT_MOUSEWHEELMouse wheel spun. Event data contains delta clicks
EVENT_MOUSEENTERMouse entered gadget area
EVENT_MOUSELEAVEMouse left gadget area
EVENT_TIMERTICKTimer ticked. Event source contains timer object
EVENT_HOTKEYHITHot key hit. Event data and mods contains hotkey keycode and modifier
EVENT_MENUACTIONMenu has been selected
EVENT_WINDOWMOVEWindow has been moved
EVENT_WINDOWSIZEWindow has been resized
EVENT_WINDOWCLOSEWindow close icon clicked
EVENT_WINDOWACTIVATEWindow activated
EVENT_WINDOWACCEPTDrag and Drop operation was attempted
EVENT_GADGETACTIONGadget state has been updated
EVENT_GADGETPAINTA Canvas Gadget needs to be redrawn
EVENT_GADGETSELECTA TreeView Node has been selected
EVENT_GADGETMENUUser has right clicked a TreeView Node or TextArea gadget
EVENT_GADGETOPENA TreeView Node has been expanded
EVENT_GADGETCLOSEA TreeView Node has been collapsed
EVENT_GADGETDONEAn HTMLView has completed loading a page
------

Types

TypeDescription
TEventEvent object type

Functions

Function EmitEvent( event:TEvent )

Emit an event

Runs all EmitEventHook hooks, passing event as the hook data.

Example

SuperStrict

Graphics 640,480

Local myEventID:Int = AllocUserEventId("My optional event description")
Local myEvent:TEvent = CreateEvent(myEventID)
Local myTimer:TTImer = CreateTimer(10, myEvent)
Local myQuitEventID:Int = AllocUserEventId("We want to quit now")
Local myQuitEvent:TEvent = CreateEvent(myQuitEventID)

Repeat
    WaitEvent
    Cls
    Select EventID()
        Case myEventID
            DrawText "Timer has ticked " + TimerTicks(myTimer) + " times",10,15
            
            ' exit application after 50 ticks
            If TimerTicks(myTimer) = 50
                EmitEvent(myQuitEvent)
            EndIf
        Case myQuitEventID
            End
    End Select
    Flip
Until AppTerminate()


Function CreateEvent:TEvent( id:Int,source:Object=Null,data:Int=0,mods:Int=0,x:Int=0,y:Int=0,extra:Object=Null)

Create an event object

Returns

A new event object

Example

SuperStrict

Graphics 640,480

Const MY_EVENT:Int = 99
Local myEvent:TEvent=CreateEvent(MY_EVENT)
Local myTimer:TTImer = CreateTimer(10,myEvent)
Repeat
    WaitEvent
    Cls
    If EventID() = MY_EVENT
        DrawText "Timer has ticked " + TimerTicks(myTimer) + " times",10,15
    EndIf
    Flip
Until AppTerminate()


Function AllocUserEventId:Int( description$="" )

Allocate a user event id

Returns

A new user event id

Example

SuperStrict

Graphics 640,480

Local myEventID:Int = AllocUserEventId("My optional event description")
Local myEvent:TEvent = CreateEvent(myEventID)
Local myTimer:TTImer = CreateTimer(10, myEvent)
Repeat
    WaitEvent
    Cls
    If EventID() = myEventID
        DrawText "Timer has ticked " + TimerTicks(myTimer) + " times",10,15
    EndIf
    Flip
Until AppTerminate()


Globals

Global EmitEventHook:Int=AllocHookId()

Hook id for emitted events

The EmitEventHook global variable contains a hook id for use with AddHook.

Each time EmitEvent is called, the event is passed to all EmitEventHook hook functions by means of the hook function data parameter.


← BRL.EndianStreamTEvent →
  • Types
  • Functions
    • Function EmitEvent( event:TEvent )
    • Function CreateEvent:TEvent( id:Int,source:Object=Null,data:Int=0,mods:Int=0,x:Int=0,y:Int=0,extra:Object=Null)
    • Function AllocUserEventId:Int( description$="" )
  • Globals
    • Global EmitEventHook:Int=AllocHookId()
BlitzMax
Docs
Getting StartedDownloadsAbout
Community
ResourcesSyntaxBomb Forums
More
GitHubStarChat on Discord
Copyright © 2022 Bruce A Henderson