As it’s extremely difficult to replicate the Roblox behaviour regarding tracking the focused button (or well, any Active element I suppose?) using e.g. MouseEnter and MouseLeave, it’d be awesome if we could just track whatever Roblox internally regards as the “focused” element. A bit like how we can fetch the current focused TextBox.
Both a simple property/method that we can use to get the current focused element and an event that triggers when it changes would be desired in my eyes. Bonus if the “pressed down” state is included too, somehow.
Example use cases:
Tooltips actually showing up for the element they’re supposed to show up for
Custom hover/down button styles properly corresponding to the internal Roblox state
I haven’t managed to replicate the way Roblox handles the focused element that way. Especially with layered buttons I somehow often end up with the “deeper” button getting assumed focus rather than the “top” one Roblox properly recognizes internally.
Somehow those events also tend to leave elements stuck in a hovered state, never firing MouseLeave (but ensuring at most one element can be in hover state improves it a lot).
@Sharksie:
We’d have to loop through all GUI elements in our game, which would cause performance issues if we’re doing it every frame. Yes, we could optimize that, but UIS already keeps track of the current GUI object (see linked thread) and: