WoW:API CreateFrame: Difference between revisions

m
m (→‎Notes: stray comma)
Line 35: Line 35:
* CreateFrame() was added in 1.10
* CreateFrame() was added in 1.10
* The fourth argument, inheritFrame, was added in 1.11
* The fourth argument, inheritFrame, was added in 1.11
* The frame's OnLoad handler, which will only exist if inherited, will be executed during the CreateFrame call. Any OnLoad script handlers set after CreateFrame() will not execute; consider adding any non-inherited OnLoad code directly after a CreateFrame call or use XML frames instead.
* The frame's [[UIHANDLER_OnLoad|OnLoad handler]], which will only exist if inherited, will be executed during the CreateFrame call. Any OnLoad script handlers set after CreateFrame() will not execute; consider adding any non-inherited OnLoad code directly after a CreateFrame call or use XML frames instead.
* The returned pointer is not necessary if you pass a frame name, however it is advised you store the pointer in a local instead of using the global name whenever possible for performance reasons.
* The returned pointer is not necessary if you pass a frame name, however it is advised you store the pointer in a local instead of using the global name whenever possible for performance reasons.
* See also [[API_Frame_SetScript]] to handle OnFunction scripts when not using a template.
* See also [[API_Frame_SetScript]] to handle OnFunction scripts when not using a template.
Line 43: Line 43:
** Creating frames on the fly for occasions when you don't know how many frames will be needed.
** Creating frames on the fly for occasions when you don't know how many frames will be needed.
** Creating infrequently used frames "on demand", for example: config dialogs, raid frames.
** Creating infrequently used frames "on demand", for example: config dialogs, raid frames.
* Never forget to unset the frames parent, if you want to get rid of a frame. I would suggest to hide the frame via frame:[[API_Region_Hide|Hide]]() and to use frame:[[API_Region_SetParent|SetParent]](nil) afterwards (this will remove the frame from its parents child list). If you just hide the frame without this additional step, frames created afterwards will get a higher [[FrameLevel|framelevel]] then the hidden one. After a while you will get frames at maximum [[FrameLevel|framelevel]] which are likely to be drawn in a distorted way (false order caused by equal [[FrameLevel|framelevel]]).
* Never forget to unset the frames parent, if you want to get rid of a frame. I would suggest to hide the frame via frame:[[API_Region_Hide|Hide]]() and to use frame:[[API_Region_SetParent|SetParent]](nil) afterward (this will remove the frame from its parents child list). If you just hide the frame without this additional step, frames created afterward will get a higher [[FrameLevel|framelevel]] than the hidden one. After a while, you will get frames at maximum [[FrameLevel|framelevel]] which are likely to be drawn in a distorted way (false order caused by equal [[FrameLevel|framelevel]]).
Anonymous user