Thread Tools Display Modes
12-23-13, 07:32 AM   #21
Phanx
Cat.
 
Phanx's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2006
Posts: 5,617
Originally Posted by Mayron View Post
I have an issue though as before I was using:
CUSTOM_CLASS_COLORS:RegisterCallback("OnColorsChanged", MayronUI)
That is not the correct order of arguments. It should be:
CUSTOM_CLASS_COLORS:RegisterCallback(MayronUI, "OnColorsChanged")

Originally Posted by Mayron View Post
I am using "function MayronUI:OnInitialize()" which I thought works the same way as OnEnable. I will try using that and if that does not work then I shall make an OnEnable function.
OnInitialize corresponds to the ADDON_LOADED event for your addon. OnEnable corresponds to PLAYER_LOGIN. Depending on the order in which addons are loaded on your system, you may be able to access CUSTOM_CLASS_COLORS in your OnInitialize, but you can't assume that will hold true for others. Either add a separate PLAYER_LOGIN event handler, or just use the OnEnable method AceAddon already provides for you, and initialize all your CUSTOM_CLASS_COLORS-related code there.
__________________
Retired author of too many addons.
Message me if you're interested in taking over one of my addons.
Don’t message me about addon bugs or programming questions.
  Reply With Quote
12-23-13, 10:13 AM   #22
Mayron
A Frostmaul Preserver
 
Mayron's Avatar
AddOn Author - Click to view addons
Join Date: Jan 2010
Posts: 275
Originally Posted by Phanx View Post
That is not the correct order of arguments. It should be:
CUSTOM_CLASS_COLORS:RegisterCallback(MayronUI, "OnColorsChanged")
When I used that I get this UI error:

Code:
Message: Interface\AddOns\!ClassColors\ClassColors.lua:78: Bad argument #1 to :RegisterCallback (string or function expected)
Time: 12/23/13 14:52:49
Count: 1
Stack: [C]: in function `assert'
Interface\AddOns\!ClassColors\ClassColors.lua:78: in function `RegisterCallback'
Interface\AddOns\MayronUI\Core.lua:2837: in function <Interface\AddOns\MayronUI\Core.lua:2836>
(tail call): ?
[C]: ?
[string "safecall Dispatcher[1]"]:9: in function <[string "safecall Dispatcher[1]"]:5>
(tail call): ?
...ace\AddOns\Masque\Libs\AceAddon-3.0\AceAddon-3.0.lua:558: in function `EnableAddon'
...ace\AddOns\Masque\Libs\AceAddon-3.0\AceAddon-3.0.lua:651: in function <...ace\AddOns\Masque\Libs\AceAddon-3.0\AceAddon-3.0.lua:636>
[C]: in function `LoadAddOn'
Interface\FrameXML\UIParent.lua:307: in function `UIParentLoadAddOn'
Interface\FrameXML\UIParent.lua:381: in function `TimeManager_LoadUI'
Interface\FrameXML\UIParent.lua:741: in function <Interface\FrameXML\UIParent.lua:706>

Locals: <none>
EDIT: I still get this Lua error when using it like this:

Lua Code:
  1. function MayronUI:OnEnable()
  2.     CUSTOM_CLASS_COLORS:RegisterCallback(MayronUI, "OnColorsChanged")
  3. end

Last edited by Mayron : 12-23-13 at 04:59 PM.
  Reply With Quote
12-23-13, 10:25 AM   #23
Dridzt
A Pyroguard Emberseer
 
Dridzt's Avatar
AddOn Author - Click to view addons
Join Date: Nov 2005
Posts: 1,362
I'm not somewhere that I can test but I seem to recall that you can only pass a function name as string when that function is a member of your object.

Ie what you've written requires that a MayronUI:OnColorsChanged function exists.

Otherwise you'd have to register callback to an actual function, not a function name.
  Reply With Quote
12-23-13, 12:22 PM   #24
Vrul
A Scalebane Royal Guard
 
Vrul's Avatar
AddOn Author - Click to view addons
Join Date: Nov 2007
Posts: 404
Originally Posted by Mayron View Post
When I used that I got a Lua error as I previously posted:

Message: Interface\AddOns\!ClassColors\ClassColors.lua:78: Bad argument #1 to :RegisterCallback (string or function expected)
I think you want to call that as a function and not as a method ( . not : )
Code:
CUSTOM_CLASS_COLORS.RegisterCallback(MayronUI, "OnColorsChanged")
  Reply With Quote
12-23-13, 07:28 PM   #25
Phanx
Cat.
 
Phanx's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2006
Posts: 5,617
Originally Posted by Vrul View Post
I think you want to call that as a function and not as a method ( . not : )
No. This isn't using CallbackHandler-1.0, so it's not the same syntax as registering callbacks with a CallbackHandler lib.

Originally Posted by Dridzt View Post
Ie what you've written requires that a MayronUI:OnColorsChanged function exists.
Yes.

However, I was wrong (that's what I get for posting at 5am); your original syntax was correct.
CUSTOM_CLASS_COLORS:RegisterCallback("OnColorsChanged", MayronUI)
It will still fail if MayronUI:OnColorsChanged() isn't defined, though.

Originally Posted by Mayron View Post
The SUF code works. ... I added it to the GetColor function which seems to be a bad idea as it causes the color wheel to respond very slowly when altering the colors due to having to run the for loop over and over again. Not sure where else to place it though.
I'm not 100% sure this will work with AceConfig, but try adding this to your set function:
if ColorPickerFrame:IsShown() then return end
This will (or should, maybe) cause the color to only be updated once the color picker is closed.
__________________
Retired author of too many addons.
Message me if you're interested in taking over one of my addons.
Don’t message me about addon bugs or programming questions.

Last edited by Phanx : 12-23-13 at 07:31 PM.
  Reply With Quote
12-24-13, 08:31 AM   #26
Mayron
A Frostmaul Preserver
 
Mayron's Avatar
AddOn Author - Click to view addons
Join Date: Jan 2010
Posts: 275
No worries Phanx
The "if not ColorPickerFrame:IsShown() then" code worked perfectly. I should have thought of that myself but I was also working late till 3:00am. Not as bad as you but I know the feeling hehe

Thanks again! Everything is working great now.
  Reply With Quote

WoWInterface » Developer Discussions » Lua/XML Help » Need help - color wheel with wowace


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off