DRGBPicker/OnChange

From Garry's Mod
Jump to: navigation, search
 DRGBPicker:OnChange( )

Contents

DescriptionPanelHook

Function which is called when the cursor is clicked and/or moved on the color picker. Meant to be overridden.

Arguments

table col

The color that is selected on the color picker (Color structure form).

Examples

Example

Creates a color picker which controls the color of a ball image.

-- Frame
MainFrame = vgui.Create("DFrame")
MainFrame:SetSize(200, 200)
MainFrame:Center()
MainFrame:SetTitle("Pick a color")

-- Image of a ball
local ball_img = vgui.Create("DImage", MainFrame)
ball_img:SetPos(20, 45)
ball_img:SetSize(128, 128)

ball_img:SetImage("sprites/sent_ball")

-- Vertical color picker
local color_picker = vgui.Create("DRGBPicker", MainFrame)
color_picker:SetPos(165, 30)
color_picker:SetSize(25, 150)

function color_picker:OnChange(col)

	ball_img:SetImageColor(col)
	
end

Output:



DModelPanel OnChange example1.gif
Personal tools
Navigation