Garry's Mod Wiki

Revision Difference

DRGBPicker:OnChange#515411

<function name="OnChange" parent="DRGBPicker" type="panelfunc">⤶ <ispanel>yes</ispanel>⤶ <description>Function which is called when the cursor is clicked and/or moved on the color picker. Meant to be overridden.</description>⤶ <realm>Client</realm>⤶ <args>⤶ <arg name="col" type="table">The color that is selected on the color picker (&lt;page&gt;Color&lt;/page&gt; form).</arg>⤶ </args>⤶ </function>⤶ ⤶ <example>⤶ <description>Creates a color picker which controls the color of a ball image.</description>⤶ <code>⤶ -- 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⤶ </code>⤶ <output></output>⤶ ⤶ </example>