Hacker News new | ask | show | jobs
by panic 1957 days ago
Immediate mode is great, but it can be hard to implement nice custom event handling on top of it. For example, say you have a collection of buttons. You want to be able to click on one button (the button highlights), drag onto another button (that button highlights and the first button unhighlights), and release on that second button to trigger its action. This is a real issue I ran into while building an immediate-mode UI... I found it hard to implement an interaction like this without a reified "layout" that I could query as the mouse moved around.
1 comments

I was doing something like that with Godot [1], the approach I took was setting some global "dragged_item" when the drag started, and then each drop target would check if the dragged_item was compatible and if the mouse was within its bounds. This way each drop target would do the check instead of some drag manager having to check whatever was under the cursor.

[1] https://github.com/0xafbf/aether/tree/master/addons/godot_im...