1. I would like the main window for my addon to fade-out when the user takes their mouse away from the window, and solidify again when the mouse is brought back over the window.

    This is what I've done so far:

     -- When mouse enters main frame
     function MainFrame_OnEnter(self, motion)
     -- When mouse leaves main frame
     function MainFrame_OnLeave(self, motion)

    These are set as the _OnEnter and _OnLeave events for my window's main frame. When the mouse enters the frame, the frame and all of it's attached widgets solidify nicely, and when the mouse leaves the frame, the entire addon fades out as expected.

    However, with the mouse in the addon's main window, when the user mouses over any of this window's many button widgets, the window fades out again--presumably, because the _OnLeave event for the frame is triggered and I don't have similar _OnEnter events programmed for each of the widgets present on the main window.

    My question is: Do I really have to have _OnEnter events programmed for each widget to accomplish a complete fade-in for everything on the window? It seems like a lot of code.


    Yes, you'll need to write code to handle this. The OnEnter and OnLeave scripts are triggered just when you'd expect them to, which doesn't work for your specific situation. You could write a script that iterates over the main frame and all of its children to set the OnEnter/OnLeave scripts so you don't have to do it all manually. Alternatively you could have an OnUpdate for the frame (it will only be active when the frame is shown, by definition) and have it check to see if the mouse is within the bounds of your frame (or checking if GetMouseFocus()'s parent chain ends in your frame), altering the alpha accordingly.

    That'd be a nice/good snippet to write, actually.

    How would I iterate through the parent chain? Is there an example of how to do so in the book somewhere (I can't find one)?

    I suppose I could do this recursively with GetParent() == UIParent as the exit condition, but if I'm scanning the parent chain / mouse's GetFocus every time the frame updates, won't this burn up a lot of CPU time? Seems heavy (but I'm probably wrong).

    I think this would be an ideal solution, but I'm not sure where to start.


    Or maybe my exit parent is WorldFrame but still, this seems heavy.

    Am I approaching this correctly?

    Your exit condition is GetParent() == nil. Here's an example of what you could do:

    Change the alpha on a frame in response to mouse

    Thanks for your answer. While I was waiting for it (since this post was broken for a while) I wrote a routine that was pretty much exactly this. Mine, however, was not as clean as I used if..then instead of while. :(

    Now, I do have it all working, but I have another interesting problem as a result. The frame that I'm fading has a texture layered on top of it as well as a button; both of which are laid over in such a fashion that they cover up part of the frame's border. This is all well and good while the transparency is 1. (You can see an example of what they look like at http://wow.curse.com/downloads/wow-addons/details/checkmate.aspx See the Main Window image and how the title box and Ready? button lay over the border.)

    However, when I change the opacity of the frame to, say 0.5, I can now see through the title box and Ready? button and the underlying frame border is visible.

    Is there any way to maintain a relative opacity for the frame's children?

    Thanks again!

    edit - made the link a link

    No, opacity carries from parent to child.