Extend MouseEnter/MouseLeave (GuiObject) to fire in more scenarios

Currently, MouseEnter and MouseLeave do not fire under enough cases for it to be useful in anything but static GUIs. Roblox will only fire these events if the mouse has moved. This prevents them from firing in a number of necessary cases for proper GUI handling. They will not fire when:

  • The GUI has made any transformation (translate/rotate/scale)
  • The GUI’s visibility (apparent) has changed while the cursor is in its bounds
  • The window size changes (rare, but possible, e.g. swapping into/out of fullscreen)

The first two cases most commonly show in scrolling frames or tweening GUI elements, and becomes painfully obvious when hovering is used to render a tooltip. Scrolling a menu or tweening it elsewhere will cause the tooltip to remain on-screen unless the user moves their cursor, as it will not detect that the GUI element is no longer under the cursor (same case applies in inverse, when an element appears under an unmoved cursor, tooltip will not appear).

Making MouseEnter/MouseLeave fire in these scenarios would cover all major use cases for these events, and prevent graphical bugs in GUI systems caused by dynamic GUI elements, and ensures these events are up to date with the modern GUI standards on Roblox.

A similar suggestion was made in a slightly different location, see GuiObject.VisibleOnScreen, which would also be useful for writing a custom system to handle these events.

15 Likes

I’d like to add on that there should be a way to detect mouse events for scroll bars themself, inside of a scrolling frame. Currently scrolling frames feel extremely static.

1 Like