1. Hello, and thanks for taking the time to read this request for assistance.

    How can one use hooksecurefunc to hook onto a function attached to a virtual element's event? I'm looking at BlizzardGarrisonUI/BlizzardGarrisonLandingPage.{xml,lua}, and here's what I'm trying to figure out:

    in Blizzard_GarrisonLandingPage.xml:

     <Ui ...>
         ...
         <Button name="GarrisonLandingPageTabTemplate" virtual="true">
         ...
             <Scripts>
                 ...
                 <OnClick function="GarrisonLandingPageTab_OnClick" />
             </Scripts>
         </Button>
     </Ui>
    

    in Blizzard_GarrisonLandingPage.lua, line 49:

     function GarrisonLandingPageTab_OnClick(self)
         ...
     end
    

    in my.lua:

     hooksecurefunc("GarrisonLandingPageTab_OnClick", function(...)
         print("Tab click detected.");
     end);
    

    As you might guess, at this moment that print() is not firing. No Lua error is thrown, though, which to me means that hooksecurefunc actually hooked my function to a function named "GarrisonLandingPageTab_OnClick" in the global scope, but I'm thinking there's something about the way tab templates work that this isn't going to work... I haven't read through that code yet, which is going to be my next step.

    I'm posting this question because I haven't seen any documentation or forum posts from my Google searching that specifically refer to how to do this. I'm still looking for the answer on my own, and I feel like I'm about to find it, and when that happens I'll put my answer here and other addon development sites, but for now I lack the knowledge required to do what I want to do.

    I suspect that hooking the aforementioned OnClick function directly won't work due to the virtual-ness of the element to which it is attached. I don't want to do an iteration through the instantiated tabs if I can help it, as I feel like a clean solution would be to somehow hook the function before those tabs are instantiated, and have my addon code attach to those tabs automatically.

    Anyway, thanks for reading this, and thanks for any assistance anyone might be able to render. Have a good day.

    -TJ

  2. Sure enough, hooksecurefunc doesn't work on functions defined as events for XML elements with virtual="true".

    What I ended up doing was using GarrisonLandingPage1:HookScript("OnClick", function() ... end) and GarrisonLandingPage2:HookScript(...etc...) to get the behavior I wanted.

    I hope this helps someone out there.

    -TJ