Finally got back to this, and two questions arose:
Code:
function ShowColorPicker(r, g, b, a, changedCallback)
ColorPickerFrame.hasOpacity, ColorPickerFrame.opacity = (a ~= nil), a;
ColorPickerFrame.previousValues = {r,g,b,a};
ColorPickerFrame.func, ColorPickerFrame.opacityFunc, ColorPickerFrame.cancelFunc =
changedCallback, changedCallback, changedCallback;
ColorPickerFrame:SetColorRGB(r,g,b);
ColorPickerFrame:Hide(); -- Need to run the OnShow handler.
ColorPickerFrame:Show();
end
local function myColorCallback(restore)
local newR, newG, newB, newA;
if restore then
-- The user bailed, we extract the old color from the table created by ShowColorPicker.
newR, newG, newB, newA = unpack(restore);
else
-- Something changed
newA, newR, newG, newB = OpacitySliderFrame:GetValue(), ColorPickerFrame:GetColorRGB();
end
-- Update our internal storage.
print(newR, newG, newB, newA);
end
ShowColorPicker(r, g, b, a, myColorCallback);
1st Question:
Code:
local myPackedColor = {1, 1, 1, 1};
ShowColorPicker(unpack(myPackedColor), myColorCallback);
When I do this,
ShowColorPicker() only gets the first return value of
unpack() as its first argument, the second argument is already the
myColorCallback function. Is there a correct way of doing this? For other functions like e.g.
SetColorTexture(unpack(myPackedColor)) it works.
2nd Question:
Is there a way to pass additional arguments to the
changedCallback function? Or do I have to do this with "public" variables?