[LWJGL] Proper Way to Handle GUI Input.

I’ve been working on a basic all-in-one 2D game library using LWJGL.

The UI that I created works fine just sometimes events are lost, or something.

I am currently polling the input for the UI and if a UI object returns true it breaks the loop through in my listener.

Is polling the best way to do this?
How else can I do this?

Lets make this a discussion!

If events are lost in the UI ‘sometimes’, the UI is not working properly.

So polling is the proper way?

Polling is prone to lose events. Use the event based API.

Can you link or show me a quick example? The only 2 ways that I know of handling events is every update to loop through all the handlers in my UI in zorder and break the loop on a hit. Or using something like Keyboard.isKeyDown(). But how would I use the latter for, say a textbox without having to write out all possible keys?

LWJGL has event methods built in Keyboard class.

Nevermind I had it backwards. I’ve been doing event-driven. But I loop through all events once an update. I’m doing something like this


while(Keyboard.next()) {
    forward to listeners
}