• Derma quick question
    3 replies, posted
A quick question, if I make a button with an image or an image button how can I change the background color when the cursor hovers over it Eg. I have a painted button and when I hover my cursor over it the background changes?
Maybe this? [url]http://wiki.garrysmod.com/page/Panel/IsHovered[/url] Never done that but I know that article exists so...
Copy + Paste from my car dealer. "buy" is a DButton, and colors.* is a table. [code] local ba = false; function buy:OnCursorEntered() ba = true; end function buy:OnCursorExited() ba = false; end buy.Paint = function() if (ba) then draw.RoundedBox(0, 0, 0, buy:GetWide(), buy:GetTall(), colors.buy_hover); else draw.RoundedBox(0, 0, 0, buy:GetWide(), buy:GetTall(), colors.buy); end local txt = "Buy Car"; if (LocalPlayer():OwnsCar(car)) then txt = "Sell Car"; end draw.SimpleText(txt, "carsBtn", buy:GetWide() / 2, 10, colors.text, TEXT_ALIGN_CENTER); end [/code] [editline]11th July 2014[/editline] Never used his method, but I'm sure it would work too.
^ I ended up coming up with something just like that a week or two ago - and can confirm that it works fine. Would recommend. A++
Sorry, you need to Log In to post a reply to this thread.