The WheelForward event fires when a user scrolls their mouse wheel forward when the mouse is over a
GuiObject|GUI element. It is similar to
Mouse/WheelForward, which fires regardless whether the user’s mouse is over a GUI element.
This event fires merely as an indicator of the wheel’s forward movement. This means that the x and y mouse coordinate arguments do not change as a result of this event. These coordinates only change when the mouse moves, which can be tracked by the
The mouse’s x screen coordinate in pixels, relative to the top left corner of the screen
The y coordinate of the user’s mouse
Custom Scrolling GUI
The example below creates a custom scrolling frame using a
Frame to mimic a
ScrollingFrame using the
The example works by moving a Frame that is the child of our CustomScrollingFrame and parent to the
TextBox|TextBoxes. Thus, we use a Frame to act as a container for the GUI elements we want to scroll. The script adjust’s the
DataType/UDim2 Y scale position of the Frame between 0 and -1 when the user scroll’s their mouse forward and backward to mimic the scrolling of a traditional ScrollingFrame element.
Although this is a simple application of the MouseWheel events, it can be expanded upon for more complex
GuiObject|GUI layouts and interaction such as custom ScrollingFrames that scroll at different rates or with different elasticity.
The gif below demonstrates the expected functionality of the code based on the GUI layout also shown below.