brianush1 / rbx-bettermouse

A simple module for much better mouse events on Roblox

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

rbx-bettermouse

A simple module for much better mouse events on Roblox

Usage

In your script, call initMouseOverlay(screenGui), or call it without any parameters to automatically generate a ScreenGui. Then, use the mouseEvents function as such:

function mouseEvents(item: GuiObject, button: 1 | 2, events: { Enter?, Up?, Down?, Leave?, Move?, Click?, DoubleClick? })

Roact

If you are using Roact, you may also call bindToRoact. Example:

BetterMouse.initMouseOverlay()
BetterMouse.bindToRoact(game:GetService("ReplicatedStorage"):WaitForChild("Roact"))

This will replace the Mouse* events with BetterMouse alternatives. To use the raw Mouse* events, prefix them with raw. So if you want to use the raw MouseButton1Down event rather than the BetterMouse alternative, use [Roact.Event.RawMouseButton1Down]

Improvements over regular Roblox events

Roblox MouseUp does not fire if the user moves their mouse outside of the GuiObject's bounding box while keeping the mouse down. The MouseLeave and MouseEnter functions are also not reliable. These issues have both been fixed in this module.

About

A simple module for much better mouse events on Roblox

License:Apache License 2.0


Languages

Language:Lua 100.0%