Posted by Philburt on Sun, 22 Jan 2012 13:27:42
If I had two addons loaded, (addon1 and addon2), how would I get addon2 to hook a button click in addon1.
For instance, addon1 with a button called Button1, includes the XML script:
<Scripts> <OnClick> DoSomeCode(); </OnClick> </Scripts>
After this button is clicked, and the DoSomeCode() routine is finished, I want addon2 to run another function, for example NowDoSomeMoreCode(). I've tried putting the following LUA into Addon2:
if (IsAddOnLoaded("addon1")) then Button1:HookScript("DoSomeCode",NowDoSomeMoreCode) end
Swatter gives the error report that 'Button1 doesn't have a DoSomeCode script'.
Am I missing something obvious? Or should it be done another way, or is what i'm trying impossible? Any ideas (as always) would be gratefully received.
Posted by Philburt on Sun, 22 Jan 2012 14:01:33
Oh - silly me. Within 5 mins of posting this i realised what I'd done wrong.
The second bit of code should have been
if (IsAddOnLoaded("addon1")) then Button1:HookScript("OnClick",NowDoSomeMoreCode) end
An obvious error really, but spent hours trying to make it work, only to realise the error after posting for help and making a coffee.
Still, i've put the correction here for anyone else to read in case they need to do it sometime.