1. #1
    Brewmaster Taurous's Avatar
    10+ Year Old Account
    Join Date
    Aug 2009
    Location
    Vancouver Island
    Posts
    1,446

    ColorPickerFrame callback help

    EDIT: I figured it out... using "." instead of ":" and r, g, b, a are nil...

    Hello, I'm trying to learn how to use the ColorPickerFrame that Blizzard provides but I'm having some issue. I'm not sure if the information on WoWPedia is incorrect or if I have a Lua issue. Here's my reference: http://wowwiki.wikia.com/wiki/Using_...lorPickerFrame

    From what I have figured out, the CC_ColorCallback function stops executing after the if, else, end block before setting CC_Color and CC_Title colors. I have placed some chat messages in there to see that. Cancel is printed correctly when I hit cancel on the color picker. Change is printed whenever a value changes in the color picker. But nothing executes after that, the colors dont change/dont print. I cannot figure out why this is.

    Thanks in advance.

    Here's my code:

    Code:
    local CC_Color = {
    	r = 0,
    	g = 0,
    	b = 0,
    	a = 0.7
    }
    
    function CC_ColorCallback(restore)
    	local newR, newG, newB, newA
    	
    	if restore then
    	--Test message
    	DEFAULT_CHAT_FRAME:AddMessage("Cancel")
    	newR, newG, newB, newA = unpack(restore)
    	else
    	--Test message
    	DEFAULT_CHAT_FRAME:AddMessage("Change")
    	newA = OpacitySliderFrame:GetValue()
    	newR, newG, newB = ColorPickerFrame:GetColorRGB()
    	end
    	
    	CC_Color.r, CC_Color.g, CC_Color.b, CC_Color.a = newR, newG, newB, newA
    	CC_Title.SetBackdropBorderColor(r, g, b, a)
    	CC_Title.setBackdropColor(r, g, b, a)
    	
    	--Test message
    	DEFAULT_CHAT_FRAME:AddMessage("r: "..r..", b: "..b..", g: "..g..", a: "..a)
    end
    
    -- Below is temporarily placed in a slash command function: /cc color will run the following.
    
    	ColorPickerFrame:SetColorRGB(CC_Color.r, CC_Color.g, CC_Color.b)
    	ColorPickerFrame.hasOpacity = true
    	ColorPickerFrame.opacity = CC_Color.a
    	ColorPickerFrame.previousValues = {CC_Color.r, CC_Color.g, CC_Color.b, CC_Color.a}
    	ColorPickerFrame.func = CC_ColorCallback
    	ColorPickerFrame.opacityFunc = CC_ColorCallback
    	ColorPickerFrame.cancelFunc = CC_ColorCallback
    	ColorPickerFrame:Hide()
    	ColorPickerFrame:Show()
    Last edited by Taurous; 2018-07-13 at 06:32 AM.

  2. #2
    For future reference, wowpedia is located at https://wow.gamepedia.com. wowwiki.wikia.com was abandoned many years ago.
    Originally Posted by Zarhym (Blue Tracker)
    this thread is a waste of internet

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •