1. Hello again,

    My add-on in development will use a number of small icon-like frames which can be dynamically created, positioned, and deleted by the user. I understand that frames cannot be destroyed, only hidden and possibly reused. I would like to create a "Frame Recycle Bin" of sorts so that before calling CreateFrame, the add-on can check to see if there is a deleted frame available to be reused.

    My question is, is it possible to check the inheritance properties of a frame? Because it would seem that if the add-on wants to create a new Button, it should only reuse a frame that was originally created as a Button. That's easy enough, I can just check the GetObjectType() of the recycled frame; but I also use virtual templates, and therefore I would want to make sure that the templates match, as well. Otherwise, I could end up recycling a frame that doesn't inherit from the template that the new object needs functionality from.

    Does any of that make any sense whatsoever?!

    Thanks for your consideration.

  2. Hello again,

    My add-on in development will use a number of small icon-like frames which can be dynamically created, positioned, and deleted by the user. I understand that frames cannot be destroyed, only hidden and possibly reused. I would like to create a "Frame Recycle Bin" of sorts so that before calling CreateFrame, the add-on can check to see if there is a deleted frame available to be reused.

    My question is, is it possible to check the inheritance properties of a frame? Because it would seem that if the add-on wants to create a new Button, it should only reuse a frame that was originally created as a Button. That's easy enough, I can just check the GetObjectType() of the recycled frame; but I also use virtual templates, and therefore I would want to make sure that the templates match, as well. Otherwise, I could end up recycling a frame that doesn't inherit from the template that the new object needs functionality from.

    Does any of that make any sense whatsoever?!

    You can't check to see what a frame inherited from when it was created, but you have complete control over this when you're constructing them. So only put 'ButtonA' frames into the 'ButtonA' pool, and when you need a 'ButtonA', just use that frame pool to get it back.

    Does that make sense?

  3. Yes, perfect sense. In fact, that's what I ended up doing; created a "RecycleBin" module that intelligently sorts various frames into tables based on a tag that is added after FrameCreate.

    Ok, next question!

    I have a small child frame that is freely draggable within the boundaries of a larger, parent frame. (If the user drag-drops the child outside of the parent, the child automatically "snaps back" to just inside the nearest edge of the parent.) Right now, in OnDragStop() I am anchoring the child to the parent in what feels like a complicated way: getting Left/Bottom of the parent, getting Left/Bottom of the child, and doing some subtraction. Is there a way to more easily anchor a child to its current position on a parent in OnDragStop()?

    Unfortunately, it seems like the unanchoring/anchoring isn't happening automatically. I do ClearAllPoints() in OnDragStart(), and then manually SetPoint() in OnDragStop(). I seem to recall that if I did not ClearAllPoints() first, some funky things would result.

  4. Yes, perfect sense. In fact, that's what I ended up doing; created a "RecycleBin" module that intelligently sorts various frames into tables based on a tag that is added after FrameCreate.

    Ok, next question!

    I have a small child frame that is freely draggable within the boundaries of a larger, parent frame. (If the user drag-drops the child outside of the parent, the child automatically "snaps back" to just inside the nearest edge of the parent.) Right now, in OnDragStop() I am anchoring the child to the parent in what feels like a complicated way: getting Left/Bottom of the parent, getting Left/Bottom of the child, and doing some subtraction. Is there a way to more easily anchor a child to its current position on a parent in OnDragStop()?

    Don't use OnDragStart() and OnDragStop(). Set an OnUpdate() that does the same thing, except keeps the frame without the bounds of the parent frame. But in general, no you'll need to figure out the position of the sub-frame within the parent in order to 'anchor' it.

    Unfortunately, it seems like the unanchoring/anchoring isn't happening automatically. I do ClearAllPoints() in OnDragStart(), and then manually SetPoint() in OnDragStop(). I seem to recall that if I did not ClearAllPoints() first, some funky things would result.

    When you have something special purpose like this, I tend to do it all manually just to ensure it works.

  5. I think I understand... in OnUpdate, check to make sure that Child is within the boundaries of Parent, and if not, snap it back? If that's correct, my only concern would be that I'm calculating the relative Left/Bottom of Parent and Child 50-60 times per second, instead of just once in OnDragStop().

  6. It's math, not really a problem. You can cache the parents position and use GetCursorPosition() to calculate it. Either way, don't prematurely optimize =)

  7. Excellent, can't wait to get home to try this technique out! As always, thanks for your very prompt advice.