Button/Image Button Mouse Hover

Can we be able to change the cursor look once the mouse is hovered over a button or an image button? it’d give us more freedom of what we can do with Guis and stuff while still having everything fit perfectly.

Here is a wonderful example of why I think this is a good idea:

1 Like

Step 1: Never use image/textbuttons

One reason is this exactly. Another is that they block mouse2 from moving the camera. Also MouseEnter/Leave barely works, and input events like mouse1up don’t fire unless the mouse is over the button, even if the mouse down’d on the button and left and then up’d.

You’re better off doing a simple box collision test whenever your mouse button is pressed. Doing this also opens a door to easily change the shape of your button to whatever you want, like triangles and ellipses.

It’s the active property that does that – not the buttons themselves IIRC.

I see what you mean, but roblox has to update them sooner or later and fix the issues that they have with it. so why not address them now?

It’s technically possible now by hiding the mouse icon and just displaying an image label:

local button = script.Parent
local mouse = game.Players.LocalPlayer:GetMouse()
local icon = button.Parent.ImageLabel

button.MouseEnter:connect(function(x,y)
	game:GetService("UserInputService").MouseIconEnabled = false
	icon.Visible = true
end)

button.MouseLeave:connect(function()
	game:GetService("UserInputService").MouseIconEnabled = true
	icon.Visible = false
end)

game:GetService("RunService").RenderStepped:connect(function()
	icon.Position = UDim2.new(0, mouse.X - 25, 0, mouse.Y - 25)
end)
19 Likes

^-- same method I use, and it works fine

1 Like

[quote] It’s technically possible now by hiding the mouse icon and just displaying an image label:

[code]
local button = script.Parent
local mouse = game.Players.LocalPlayer:GetMouse()
local icon = button.Parent.ImageLabel

button.MouseEnter:connect(function(x,y)
game:GetService(“UserInputService”).MouseIconEnabled = false
icon.Visible = true
end)

button.MouseLeave:connect(function()
game:GetService(“UserInputService”).MouseIconEnabled = true
icon.Visible = false
end)

game:GetService(“RunService”).RenderStepped:connect(function()
icon.Position = UDim2.new(0, mouse.X - 25, 0, mouse.Y - 25)
end)
[/code] [/quote]

Awesome,

Though can the issues that Ethan mentioned be addressed?

Well, the blocking of mouse input is kind of a feature – set Active to false if you don’t want it to do that.