BlitzMax

BlitzMax

  • Downloads
  • Docs
  • API
  • Resources
  • About

›BRL

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
  • IO

    • Introduction
    • MaxIO
  • 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
    • SVec4D
    • SVec4F
    • SVec4I

    Volumes

    • Introduction
    • TVolume
  • BRL.WAVLoader

Text

    CSV

    • Introduction
    • TCsvParser
    • TCsvHeader
    • TCsvRow
    • TCsvOptions
    • SCsvColumn

    Format

    • Introduction
    • TFormatter

    Ini

    • Introduction
    • TIni
    • TIniProperty
    • TIniSection

    JConv

    • Introduction
    • TJConv
    • TJConvBuilder
    • TJConvSerializer

    Json

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

    Regex

    • Introduction
    • TRegEx
    • TRegExMatch
    • TRegExOptions
    • TRegExException

    TOML

    • Introduction
    • ETomlNodeType
    • TToml
    • ITomlNode
    • STomlDate
    • STomlDateTime
    • STomlTime
    • TTomlArray
    • TTomlInteger
    • TTomlString
    • TTomlTable
    • TTomlBoolean

    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.EventQueue

The event queue is a simple first-in, first-out queue that is used to collect TEvent objects emitted by your application.

The PollEvent and WaitEvent commands can be used to receive the next event from the event queue, while the PeekEvent command can be used to check if the event queue is empty.

Events are added to the event queue using PostEvent.

Functions

Function PeekEvent:TEvent()

Examine the next event in the event queue

PeekEvent examines the next event in the event queue, without removing it from the event queue or modifying the CurrentEvent global variable.

If there are no events in the event queue, PeekEvent returns Null.


Function PollEvent:Int()

Get the next event from the event queue

PollEvent removes an event from the event queue and updates the CurrentEvent global variable.

If there are no events in the event queue, PollEvent returns 0.

Returns

The id of the next event in the event queue, or 0 if the event queue is empty


Function WaitEvent:Int()

Get the next event from the event queue, waiting if necessary

WaitEvent removes an event from the event queue and updates the CurrentEvent global variable.

If there are no events in the event queue, WaitEvent halts program execution until an event is available.

Returns

The id of the next event in the event queue


Function PostEvent( event:TEvent,update:Int=False )

Post an event to the event queue

PostEvent adds an event to the end of the event queue.

The update flag can be used to update an existing event. If update is True and an event with the same id and source is found in the event queue, the existing event will be updated instead of event being added to the event queue. This can be useful to prevent high frequency events such as timer events from flooding the event queue.


Function EventID:Int()

Get current event id

Returns

The id field of the CurrentEvent global variable

Example 1

SuperStrict

Import MaxGUI.Drivers

Local MyWindow:TGadget=CreateWindow("Button Example", 200,200,320,240)
Local MyButton:TGadget=CreateButton("Click Me",140,60,80,40, MyWindow)

Repeat
  WaitEvent()
  Select EventID()
  Case EVENT_WINDOWCLOSE
     End
   End Select
Forever

Example 2

SuperStrict

Import MaxGUI.Drivers

Local window:tgadget=CreateWindow("events",0,0,320,240)

Local button:tgadget=CreateButton("Button1",4,4,80,24,window)
Local canvas:tgadget=CreateCanvas(84,4,80,24,window,1)

Repeat
    WaitEvent()
    If EventID()=EVENT_WINDOWCLOSE End
    
    Select EventID()
        Case EVENT_GADGETACTION Print "gadgetaction (buttonpress, etc.)"
        Case EVENT_MOUSEMOVE Print "canvas mousemove"
    End Select
    
Forever


Function EventData:Int()

Get current event data

Returns

The data field of the CurrentEvent global variable

Example

SuperStrict

Import MaxGUI.Drivers

Local window:tgadget=CreateWindow("leftclick/rightclick",0,0,320,240)

Local canvas:tgadget=CreateCanvas(4,4,160,160,window,1)

Repeat
    WaitEvent()
    If EventID()=EVENT_WINDOWCLOSE End
    
    Select EventData()
        Case 1 Print "leftclick"
        Case 2 Print "rightclick"
    End Select
Forever


Function EventMods:Int()

Get current event modifiers

Returns

The mods field of the CurrentEvent global variable


Function EventX:Int()

Get current event x value

Returns

The x field of the CurrentEvent global variable

Example

SuperStrict

Import MaxGUI.Drivers

Local window:tgadget=CreateWindow("move mouse",0,0,320,240)

Local canvas:tgadget=CreateCanvas(4,4,160,160,window,1)

Repeat
    WaitEvent()
    If EventID()=EVENT_WINDOWCLOSE End
    
    If EventID()=EVENT_MOUSEMOVE
        Print EventX()
    EndIf
Forever


Function EventY:Int()

Get current event y value

Returns

The y field of the CurrentEvent global variable

Example

SuperStrict

Import MaxGUI.Drivers

Local window:tgadget=CreateWindow("move mouse",0,0,320,240)

Local canvas:tgadget=CreateCanvas(4,4,160,160,window,1)

Repeat
    WaitEvent()
    If EventID()=EVENT_WINDOWCLOSE End
    
    If EventID()=EVENT_MOUSEMOVE
        Print EventY()
    EndIf
Forever


Function EventExtra:Object()

Get current event extra value

Returns

The extra field of the CurrentEvent global variable


Function EventText$()

Get current event extra value converted to a string

Returns

The extra field of the CurrentEvent global variable converted to a string

Example

'
' Drop a file onto the window to see EventText() return the path.
'
SuperStrict

Import MaxGUI.Drivers

Local window:tgadget=CreateWindow("move mouse",0,0,320,240,Null,15|WINDOW_ACCEPTFILES)

Repeat
    WaitEvent()
    If EventID()=EVENT_WINDOWCLOSE End
    
    If EventID()=EVENT_WINDOWACCEPT
        Print EventText()
    EndIf
Forever


Function EventSource:Object()

Get current event source object

Returns

The source field of the CurrentEvent global variable

Example 1

SuperStrict

Import MaxGUI.Drivers

Local MyWindow:TGadget=CreateWindow("Two Buttons Example", 200,200,320,240)
Local Button1:TGadget=CreateButton("One",140,40,80,40, MyWindow)
Local Button2:TGadget=CreateButton("Two",140,100,80,40, MyWindow)

Repeat
  WaitEvent()
  Select EventID()
  Case EVENT_WINDOWCLOSE
     End
  Case EVENT_GADGETACTION
    Select EventSource()
      Case Button1
         SetGadgetText(Button1,"One clicked")
      Case Button2
         SetGadgetText(Button2,"Two clicked")
      End Select
   End Select
Forever

Example 2

SuperStrict

Import MaxGUI.Drivers

Local window:tgadget=CreateWindow("events",0,0,320,240)

Local button1:tgadget=CreateButton("Button1",4,4,80,24,window)
Local button2:tgadget=CreateButton("Button2",84,4,80,24,window)

Repeat
    WaitEvent()
    If EventID()=EVENT_WINDOWCLOSE End
    
    Select EventSource()
        Case button1 Print "button1"
        Case button2 Print "button2"
    End Select
    
Forever


Function EventSourceHandle:Size_T()

Get current event source object handle

Returns

The source field of the CurrentEvent global variable converted to an integer handle


Globals

Global CurrentEvent:TEvent=NullEvent

Current Event

The CurrentEvent global variable contains the event most recently returned by PollEvent or WaitEvent.


← TEventBRL.FileSystem →
  • Functions
    • Function PeekEvent:TEvent()
    • Function PollEvent:Int()
    • Function WaitEvent:Int()
    • Function PostEvent( event:TEvent,update:Int=False )
    • Function EventID:Int()
    • Function EventData:Int()
    • Function EventMods:Int()
    • Function EventX:Int()
    • Function EventY:Int()
    • Function EventExtra:Object()
    • Function EventText$()
    • Function EventSource:Object()
    • Function EventSourceHandle:Size_T()
  • Globals
    • Global CurrentEvent:TEvent=NullEvent
BlitzMax
Docs
Getting StartedDownloadsAbout
Community
ResourcesSyntaxBomb Forums
More
GitHubStarChat on Discord
Copyright © 2023 Bruce A Henderson