Skip to content

Input Events

Input event methods allow you to detect and process user interaction with displays. Events are queued by DirectGPU and can be read by polling the display event queue.

Method
clearEvents(displayId : DisplayID) : ()
hasEvents(displayId : DisplayID) : boolean
pollEvent(displayId : DisplayID) : table | nil
enableMouseEvents(displayId : DisplayID, enabled : boolean, hover : boolean) : ()

Clears all queued input events for a display.

Useful when resetting a UI state or when you no longer need previously queued interactions.

Requires: DisplayID

gpu.clearEvents(displayId)

Checks whether a display has any pending input events.

Requires: DisplayID

Returns: boolean

Returns:

  • true if one or more events are waiting
  • false if the event queue is empty
if gpu.hasEvents(displayId) then
print("input waiting")
end

Returns the next queued input event from a display.

Returns nil if there are no events available.

Requires: DisplayID

Returns: Event table or nil

if gpu.hasEvents(displayId) then
local event = gpu.pollEvent(displayId)
print(event.type)
end
{
type = "click",
x = 20,
y = 30
}

Enables or disables mouse events for a display.

Requires: DisplayID, enabled : boolean, hover : boolean | nil

gpu.enableMouseEvents(id, true, true)
gpu.enableMouseEvents(id, false)