WoW:Using the ColorPickerFrame: Difference between revisions
Jump to navigation
Jump to search
Line 7: | Line 7: | ||
== ColorPickerFrame functions == | == ColorPickerFrame functions == | ||
ColorPickerFrame.func | ColorPickerFrame.func; | ||
--Called on changing the color wheel | --Called on changing the color wheel | ||
ColorPickerFrame.opacityFunc | ColorPickerFrame.opacityFunc; | ||
--Called on changing the opacity slider | --Called on changing the opacity slider | ||
ColorPickerFrame.cancelFunc | ColorPickerFrame.cancelFunc; | ||
--Called on hitting CANCEL button OR pressing ESCAPE. | |||
--cancelFunc is called with the argument ColorPickerFrame.previousValues so set that when | |||
--you show the frame | |||
These functions can be specified by you to do something. The best example is setting some variables to the selected color as it changes. Check the following code: | These functions can be specified by you to do something. The best example is setting some variables to the selected color as it changes. Check the following code: | ||
Line 20: | Line 22: | ||
ColorPickerFrame.func = MY_COLOR_FUNCTION | ColorPickerFrame.func = MY_COLOR_FUNCTION | ||
ColorPickerFrame.cancelFunc = MY_CANCEL_FUNCTION | |||
function MY_COLOR_FUNCTION() | function MY_COLOR_FUNCTION() | ||
local R,G,B = ColorPickerFrame:GetColorRGB(); | local R,G,B = ColorPickerFrame:GetColorRGB(); | ||
end | |||
function MY_CANCEL_FUNCTION(prevvals) | |||
local R,G,B = unpack(prevvals) | |||
end | end | ||
Line 28: | Line 34: | ||
== ColorPickerFrame Misc == | == ColorPickerFrame Misc == | ||
ColorPickerFrame.hasOpacity = boolean; | |||
--Sets whether or not to show the opacity slider. | |||
--You MUST set this explicitly every time as the default UI will not reset it from a value | |||
--set previously. | |||
ColorPickerFrame.opacity = Alpha; | |||
--Sets the initial value of the opacity slider. | |||
ColorPickerFrame.previousValues = {R, G, B} | |||
--Sets the values passed to the cancelFunc when Esc is pressed or the close button is pressed. | |||
ColorSwatch:SetTexture(R, G, B); | ColorSwatch:SetTexture(R, G, B); | ||
Line 45: | Line 60: | ||
--Gets the color from the color frame | --Gets the color from the color frame | ||
local A = OpacitySliderFrame:GetValue(); | |||
--Gets the opacity from the opacity slider on the color frame. | |||
== Examples of use == | == Examples of use == |
Revision as of 06:10, 16 November 2005
What is it?
The ColorPickerFrame (See: XML_User_Interface#ColorSelect) is the default WoW frame to easily select color and opacity using a GUI. The ColorPickerFrame comes with customizable functions, which are next.
ColorPickerFrame functions
ColorPickerFrame.func; --Called on changing the color wheel
ColorPickerFrame.opacityFunc; --Called on changing the opacity slider
ColorPickerFrame.cancelFunc; --Called on hitting CANCEL button OR pressing ESCAPE. --cancelFunc is called with the argument ColorPickerFrame.previousValues so set that when --you show the frame
These functions can be specified by you to do something. The best example is setting some variables to the selected color as it changes. Check the following code:
ColorPickerFrame.func = MY_COLOR_FUNCTION ColorPickerFrame.cancelFunc = MY_CANCEL_FUNCTION
function MY_COLOR_FUNCTION() local R,G,B = ColorPickerFrame:GetColorRGB(); end function MY_CANCEL_FUNCTION(prevvals) local R,G,B = unpack(prevvals) end
All the functions can be set in that manner.
ColorPickerFrame Misc
ColorPickerFrame.hasOpacity = boolean; --Sets whether or not to show the opacity slider. --You MUST set this explicitly every time as the default UI will not reset it from a value --set previously.
ColorPickerFrame.opacity = Alpha; --Sets the initial value of the opacity slider.
ColorPickerFrame.previousValues = {R, G, B} --Sets the values passed to the cancelFunc when Esc is pressed or the close button is pressed.
ColorSwatch:SetTexture(R, G, B); --Sets the color square to show specified color
ColorPickerFrame:Show(); --Shows the frame
ColorPickerFrame:Hide(); --Hides the frame
ColorPickerFrame:SetColorRGB(R, G, B); --Set the color in the color frame
local R,G,B = ColorPickerFrame:GetColorRGB(); --Gets the color from the color frame
local A = OpacitySliderFrame:GetValue(); --Gets the opacity from the opacity slider on the color frame.
Examples of use
Open frame with specified values:
ColorPickerFrame:Show(); ColorPickerFrame:SetColorRGB(R, G, B);
Set R, G, and B to the ColorWheel's colors on changing the selected color
ColorPickerFrame.func = MY_COLOR_FUNCTION function MY_COLOR_FUNCTION() local R,G,B = ColorPickerFrame:GetColorRGB(); end