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.
Methods
Section titled “Methods”| Method |
|---|
clearEvents(displayId : DisplayID) : () |
hasEvents(displayId : DisplayID) : boolean |
pollEvent(displayId : DisplayID) : table | nil |
enableMouseEvents(displayId : DisplayID, enabled : boolean, hover : boolean) : () |
clearEvents
Section titled “clearEvents”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
Example
Section titled “Example”gpu.clearEvents(displayId)hasEvents
Section titled “hasEvents”Checks whether a display has any pending input events.
Requires: DisplayID
Returns: boolean
Returns:
trueif one or more events are waitingfalseif the event queue is empty
Example
Section titled “Example”if gpu.hasEvents(displayId) then print("input waiting")endpollEvent
Section titled “pollEvent”Returns the next queued input event from a display.
Returns nil if there are no events available.
Requires: DisplayID
Returns: Event table or nil
Example
Section titled “Example”if gpu.hasEvents(displayId) then local event = gpu.pollEvent(displayId)
print(event.type)endEvent Example
Section titled “Event Example”{ type = "click", x = 20, y = 30}enableMouseEvents
Section titled “enableMouseEvents”Enables or disables mouse events for a display.
Requires: DisplayID, enabled : boolean, hover : boolean | nil
Example
Section titled “Example”gpu.enableMouseEvents(id, true, true)gpu.enableMouseEvents(id, false)