Garry's Mod Wiki

Revision Difference

DColorPalette#513289

<panel>⤶ <parent>DIconLayout</parent>⤶ <preview>DColorPalette.png</preview>⤶ <description>⤶ The **DColorPalette** allows the player to select a color from a list of given colors.⤶ ⤶ This panel supports saving across sessions via the panel cookie system.⤶ ⤶ ⤶ Use <page>Panel:SetCookieName</page> to change "save files".⤶ </description>⤶ ⤶ </panel>⤶ ⤶ ⤶ <example>⤶ <description>Creates a DColorPalette in a DFrame, clicking on a color will change the DColorButton's color to the selected color</description>⤶ <code>⤶ local Frame = vgui.Create( "DFrame" )⤶ Frame:SetSize( 170, 200 )⤶ Frame:Center()⤶ Frame:MakePopup()⤶ ⤶ local DColorPalette = vgui.Create( "DColorPalette", Frame )⤶ DColorPalette:SetPos( 5, 50 )⤶ DColorPalette:SetSize( 160, 50 )⤶ ⤶ local DColorButton = vgui.Create( "DColorButton", Frame )⤶ DColorButton:SetSize( 50, 50 )⤶ DColorButton:SetPos( 60, 100 )⤶ ⤶ -- This function is assigned AFTER DColorButton is created so we can use the DColorButton⤶ DColorPalette.OnValueChanged = function( s, value )⤶ DColorButton:SetColor( value )⤶ end⤶ </code>⤶ ⤶ </example>⤶ ⤶