Garry's Mod Wiki

DRGBPicker:OnChange

  DRGBPicker:OnChange( table col )

Description

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

Arguments

1 table col
The color that is selected on the color picker (Color form).

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: