Skip to content
dmzotov1986 edited this page Jan 30, 2025 · 5 revisions

SDL.pollEvent

Use this function to poll for currently pending events. This function is implemented as an iterator.

Function

SYNOPSIS

function SDL.pollEvent()

RETURNS

  • an iterator of event (see Event)

EXAMPLES

--
-- This is the recommended way of handling events
--
local running = true
while running do
    for e in SDL.pollEvent() do
        if e.type == SDL.event.Quit then
            running = false
        end
    end
    -- To avoid wasting processor time waiting for events by constantly spinning in a loop.
    -- The actual code may contain drawing the next frame here (or maybe at the beginning of the loop). Perhaps you will need a variable instead of a constant, or just use a timer.
    SDL.delay(100)
end

SEE ALSO

SDL.waitEvent

Clone this wiki locally