WoWInterface

WoWInterface (https://www.wowinterface.com/forums/index.php)
-   Lua/XML Help (https://www.wowinterface.com/forums/forumdisplay.php?f=16)
-   -   Ace3 GetWidth() not working (https://www.wowinterface.com/forums/showthread.php?t=59039)

Racksoup 02-04-22 07:49 PM

Ace3 GetWidth() not working
 
When I try to use GetWidth() or GetHeight() on an Ace3 frame I receive the error message 'attempt to call method 'GetWidth' (a nil value)'.

local basicFrame = ACE_GUI:Create("Frame")
basicFrame:SetHeight(200)
basicFrame:SetWidth(200)
print(basicFrame:GetWidth())

When I use a frame from CreateFrame() I can use GetWidth() and GetHeight().

I am also developing on Classic if that makes a difference.

SDPhantom 02-05-22 08:23 AM

AceGUI:Create() doesn't directly return a frame handle. It returns a table they call a "widget", though it does contain the frame handle at widget.frame. AceGUI also sets widget.frame.width when you call widget:SetWidth().

Example:
Lua Code:
  1. local ACE_GUI=LibStub:GetLibrary("AceGUI-3.0");--   Assuming you had this defined previously
  2.  
  3. local basicFrame=ACE_GUI:Create("Frame");
  4. basicFrame:SetHeight(200);
  5. basicFrame:SetWidth(200);
  6.  
  7. --  Both of these should print the same value
  8. print(basicFrame.frame.width);
  9. print(basicFrame.frame:GetWidth());


All times are GMT -6. The time now is 05:15 AM.

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