WoWInterface

WoWInterface (https://www.wowinterface.com/forums/index.php)
-   General Authoring Discussion (https://www.wowinterface.com/forums/forumdisplay.php?f=20)
-   -   frame.setEnabled() ???? (https://www.wowinterface.com/forums/showthread.php?t=56115)

demanl 03-22-18 09:17 AM

frame.setEnabled() ????
 
Hello,

I apologize if this has been already asked and answered already :(

But I'm new to wow coding and I'm working with some pretty old addon code (nUI) trying to learn and understand it all....

I came across some code that "element.frame.setEnabled( enabled);" which is generating a

"attempt to call field 'setEnabled' (a nil value)" error message.

I'm assuming that the method "setEnabled" used to exist for frames and has been removed and replaced with something better...but for the LIFE of me I can't find s**t about this anywhere...:(.

I did find that the method setEnabled exists for buttons and such...but no info of it ever having anything to do with frames.

Can anyone shine some light on this for me please....point me in the right direction...:)

TYIA :):banana:

VincentSDSH 03-22-18 09:31 AM

:SetEnabled() only has one context currently. That is not to say that it can't be added to a frame for a particular addon for a particular rationale. Excepting the above, as far as I can recall, frames weren't enabled/disabled in that way but rather by :Show(), :Hide(), and the now deprecated :IsVisible() and its replacement :IsShown().

You'd need to drop in the Lua or give us a source-addon for the code to look into it further.

Resike 03-22-18 09:50 AM

Quote:

Originally Posted by VincentSDSH (Post 327318)
:SetEnabled() only has one context currently. That is not to say that it can't be added to a frame for a particular addon for a particular rationale. Excepting the above, as far as I can recall, frames weren't enabled/disabled in that way but rather by :Show(), :Hide(), and the now deprecated :IsVisible() and its replacement :IsShown().

You'd need to drop in the Lua or give us a source-addon for the code to look into it further.

: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).

Kanegasi 03-22-18 01:17 PM

Lua object names are case-sensitive. If the error actually says "setEnabled" and the code you found says "setEnabled", try changing it to "SetEnabled".

VincentSDSH 03-22-18 05:59 PM

Quote:

Originally Posted by Resike (Post 327319)
: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).

Well that's good to know. Not what I read on the official forums years ago when :IsShown() was introduced but it has been years, and it was the official forums.

MunkDev 03-23-18 10:20 AM

Quote:

Originally Posted by Resike (Post 327319)
: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.


All times are GMT -6. The time now is 05:47 PM.

vBulletin © 2024, Jelsoft Enterprises Ltd
© 2004 - 2022 MMOUI