Quantcast frame.setEnabled() ???? - WoWInterface
Thread Tools Display Modes
03-22-18, 09:17 AM   #1
demanl
A Cyclonian
 
demanl's Avatar
Join Date: Feb 2009
Posts: 43
Cool 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
  Reply With Quote
03-22-18, 09:31 AM   #2
VincentSDSH
Non-Canadian Luzer!
 
VincentSDSH's Avatar
AddOn Author - Click to view addons
Join Date: Jun 2006
Posts: 331
: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.
__________________
AddonsExecutive Assistant User Configurable To-Do ListLegible Mail Choose the Font for Your Mail
  Reply With Quote
03-22-18, 09:50 AM   #3
Resike
A Pyroguard Emberseer
AddOn Author - Click to view addons
Join Date: Mar 2010
Posts: 1,272
Originally Posted by VincentSDSH View Post
: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).
  Reply With Quote
03-22-18, 01:17 PM   #4
Kanegasi
A Cobalt Mageweaver
 
Kanegasi's Avatar
AddOn Author - Click to view addons
Join Date: Apr 2007
Posts: 221
Lua object names are case-sensitive. If the error actually says "setEnabled" and the code you found says "setEnabled", try changing it to "SetEnabled".
  Reply With Quote
03-22-18, 05:59 PM   #5
VincentSDSH
Non-Canadian Luzer!
 
VincentSDSH's Avatar
AddOn Author - Click to view addons
Join Date: Jun 2006
Posts: 331
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).
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.
__________________
AddonsExecutive Assistant User Configurable To-Do ListLegible Mail Choose the Font for Your Mail
  Reply With Quote
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: 400
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

WoWInterface » Developer Discussions » General Authoring Discussion » frame.setEnabled() ????

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off