View Single Post
03-23-18, 10:20 AM   #6
MunkDev
A Scalebane Royal Guard
 
MunkDev's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2015
Posts: 431
Originally Posted by Resike View Post
:IsVisible() and :IsShown() is totally different, :IsShown() also returns true if the frame is outside of the UIParent and shown, while :IsVisible() only returns true of the frame in inside of the UIParent and shown aka (visible).
This description is a bit confusing.
IsShown will be true for a frame that is explicitly shown, even when its parent is not.
IsVisible will only be true when it's visible and all parents up the hierarchy are too, which may or may not end at UIParent.

Lua Code:
  1. parent:Hide()
  2. child:Show()
  3. ---------------------------
  4. child:IsShown() --> true
  5. child:IsVisible() --> false
  6.  
  7. parent:Show()
  8. child:Show()
  9. ---------------------------
  10. child:IsShown() --> true
  11. child:IsVisible() --> true
  12.  
  13. parent:Show()
  14. child:Hide()
  15. ---------------------------
  16. child:IsShown() --> false
  17. child:IsVisible() --> false

For example, state swapping a frame from hidden to shown or vice versa should be done as frame:SetShown(not frame:IsShown()). Using something like frame:SetShown(not frame:IsVisible()) would become erratic if the parent of frame isn't visible at all times.
__________________
  Reply With Quote