• Derma DButton Coloring
    4 replies, posted
When you click on the DButton, it becomes blue, when you release it returns white Can I change set its color in the same way as clicking on it without repainting the button? I was looking to make it so when the button is 'selected' that instead of the text just changing color, the actual button does
use think and paint. think to detect mouse over and set a localized color to a mouseover color, then paint it. if you override paint you will need to paint the entire button again.
local DColorButton = vgui.Create( "DColorButton", DFrame ) DColorButton:SetPos( 1, 28 ) DColorButton:SetSize( 100, 30 ) DColorButton:Paint( 100, 30 ) DColorButton:SetText( " DColorButton" ) DColorButton:SetColor( Color( 0, 110, 160 ) ) -- you can change the down here !
local DButton = vgui.Create( "DButton", DPanel ) DButton:SetPos( 5, 5 ) DButton:SetText( "single" ) DButton:SetSize( 115, 25 ) DButton:SetTextColor( Color( 255, 255, 255, 255 ) ) DButton.Paint = function(s , w , h) draw.RoundedBox(4,0,0,w , h,Color(5, 5, 40, 255)) end DButton.DoClick = function() print( "Button was clicked!" ) DButton.Paint = function(s , w , h) draw.RoundedBox(4,0,0,w , h,Color(5, 5, 40, 255)) end have not tried it idk if it'll work
[CODE] SomeButton.Paint = function(panel, w, h) if panel.Depressed then draw.RoundedBox(4, 0, 0, w, h, color_white) else draw.RoundedBox(4, 0, 0, w, h, Color(0, 0, 255)) end end [/CODE]
Sorry, you need to Log In to post a reply to this thread.