m
Move page script moved page Using the ColorPickerFrame to WoW:Using the ColorPickerFrame without leaving a redirect
(colon entities) |
m (Move page script moved page Using the ColorPickerFrame to WoW:Using the ColorPickerFrame without leaving a redirect) |
||
| (6 intermediate revisions by 6 users not shown) | |||
| Line 1: | Line 1: | ||
{{ | {{wow/uihowto}} | ||
'''ColorPickerFrame''' is a FrameXML-provided frame that is used by the UI to allow the user to customize color and opacity properties of various objects. The frame can also be used by third-party addons. | '''ColorPickerFrame''' is a FrameXML-provided frame that is used by the UI to allow the user to customize color and opacity properties of various objects. The frame can also be used by third-party addons. | ||
| Line 11: | Line 11: | ||
== Showing the color picker == | == Showing the color picker == | ||
The ColorPickerFrame is already defined by Blizzard. You can display it by simply calling: ColorPickerFrame:Show() | |||
However, displaying it is not enough if you want it to have any functionality. So, you also need to define the following three functions: | |||
* ColorPickerFrame.func() | |||
* ColorPickerFrame.opacityFunc() | |||
* ColorPickerFrame.cancelFunc() | |||
When you want to prompt the user to select a color, you need to assign your own callback functions to the ColorPickerFrame variables, set the currently selected color to your previous value, and show the ColorPickerFrame. | When you want to prompt the user to select a color, you need to assign your own callback functions to the ColorPickerFrame variables, set the currently selected color to your previous value, and show the ColorPickerFrame. | ||
| Line 21: | Line 28: | ||
ColorPickerFrame:SetColorRGB(r,g,b); | ColorPickerFrame:SetColorRGB(r,g,b); | ||
ColorPickerFrame.hasOpacity, ColorPickerFrame.opacity = (a ~= nil), a; | ColorPickerFrame.hasOpacity, ColorPickerFrame.opacity = (a ~= nil), a; | ||
ColorPickerFrame. | ColorPickerFrame.previousValues = {r,g,b,a}; | ||
ColorPickerFrame.func, ColorPickerFrame.opacityFunc, ColorPickerFrame.cancelFunc = | ColorPickerFrame.func, ColorPickerFrame.opacityFunc, ColorPickerFrame.cancelFunc = | ||
changedCallback, changedCallback, changedCallback; | changedCallback, changedCallback, changedCallback; | ||
| Line 45: | Line 52: | ||
else | else | ||
-- Something changed | -- Something changed | ||
newA, newR, newG, newB = OpacitySliderFrame:GetValue(), ColorPickerFrame:GetColorRGB; | newA, newR, newG, newB = OpacitySliderFrame:GetValue(), ColorPickerFrame:GetColorRGB(); | ||
end | end | ||
| Line 55: | Line 62: | ||
This can then be used with the previously described ShowColorPicker function: | This can then be used with the previously described ShowColorPicker function: | ||
ShowColorPicker(r, g, b, a, myColorCallback); | ShowColorPicker(r, g, b, a, myColorCallback); | ||
==Limitations== | |||
[[File:ColorPickerTools.jpg|320px|right|thumb|ColorTools.]] | |||
The color picker has three main limitations: | |||
*You have no way to know exactly which color is chosen (no color code) | |||
*You can't copy color values from one instance of the color picker to another one | |||
*You cannot move the color picker in case it obscures another underlying frame | |||
All these problems are solved with the addon [http://wow.curse.com/downloads/wow-addons/details/colortools.aspx ColorTools ]. | |||
==Note== | |||
As [[User:Exawatt|Exawatt]] stated, ColorPickerFrame:SetColorRGB(R, G, B) will execute ColorPickerFrame.func | |||
This is very important when you're reusing ColorPickerFrame with another callback function. In that case make sure you set the new callback before you call SetColorRGB(R, G, B) | |||