Quantcast
ACE3 need help with this custom widget - WoWInterface
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
06-23-19, 06:00 PM   #1
galvin
A Frostmaul Preserver
Join Date: Nov 2006
Posts: 263
ACE3 need help with this custom widget

This is a test widget that I need to fully work before I can begin my real work
This appears to work at first, but soon as the widget gets released it breaks.
Here's a video of it breaking
https://www.youtube.com/watch?v=XxK4dMjfG2Q

Code:
local WidgetVersion = 1
local WidgetType = 'GUB_TEST'

AceGUI:RegisterLayout('TestLayout',
  function(Content, Children)
    local Child = Children[1]
    local DropdownFrame = Child.frame

    DropdownFrame:ClearAllPoints()
    DropdownFrame:SetPoint('TOPLEFT', Content, 0, 1)
    DropdownFrame:Show()

    Child:SetWidth(Content:GetWidth() or 0)
    Child:SetHeight(Content:GetHeight() or 0)
    Child.frame:Show()
  end)

local function TestOnAcquire(Widget)
  local Dropdown = AceGUI:Create('Dropdown')

  Widget:SetLayout('TestLayout')
  Widget.SetLayout = function() end

  Widget:AddChild(Dropdown)
  Widget.Dropdown = Dropdown
end

local function TestOnRelease(Widget)
  Widget.Dropdown.frame:ClearAllPoints()
  Widget:SetDisabled(false)
  Widget.Dropdown = nil
end

local function TestConstructor()
  local Frame = CreateFrame('Frame', nil, UIParent)
  Frame:SetSize(50, 50)

  local Content = CreateFrame('Frame', nil, Frame)
  Content:SetAllPoints()

  local Widget = {
    frame = Frame,
    content = Content,
    type = WidgetType
  }

  -- methods
  Widget.OnRelease = TestOnRelease
  Widget.OnAcquire = TestOnAcquire

  Widget.SetText      = function(self, ...) Widget.Dropdown:SetText(...) end
  Widget.SetLabel     = function(self, ...) Widget.Dropdown:SetLabel(...) end
  Widget.SetValue     = function(self, ...) Widget.Dropdown:SetValue(...) end
  Widget.GetValue     = function(self, ...) Widget.Dropdown:GetValue(...) end
  Widget.SetList      = function(self, ...) Widget.Dropdown:SetList(...) end
  Widget.SetDisabled  = function(self, ...) Widget.Dropdown:SetDisabled(...) end

  return AceGUI:RegisterAsContainer(Widget)
end

AceGUI:RegisterWidgetType(WidgetType, TestConstructor, WidgetVersion)
  Reply With Quote
 

WoWInterface » Developer Discussions » Lua/XML Help » ACE3 need help with this custom widget

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