Quantcast
GetChecked() deprecated ? - WoWInterface
Thread Tools Display Modes
08-04-16, 08:37 AM   #1
Marsgames
An Aku'mai Servant
 
Marsgames's Avatar
Join Date: Jul 2016
Posts: 33
GetChecked() deprecated ?

Hi, when I try

Lua Code:
  1. local name = "checkButton"
  2. local template = "UICheckButtonTemplate"
  3. local checkButton = CreateFrame("Button", name, UIParent, template)
  4. checkButton:SetPoint("CENTER", 0, 0)
  5. checkButton.text = _G[name.."Text"]
  6. checkButton.text:SetText("Hello World")
  7. checkButton:SetScript("OnClick", function(self, event, arg1)
  8.   if self:GetChecked() then
  9.     print("Button is checked")
  10.   else
  11.     print("Button is unchecked")
  12.   end
  13. end)

I got an error :
Message: Interface\AddOns\GearHelper\GearHelper.lua:834: attempt to call method 'GetChecked' (a nil value)
Time: Thu Aug 4 16:34:28 2016
Count: 2
Stack: Interface\AddOns\GearHelper\GearHelper.lua:834: in function <Interface\AddOns\GearHelper\GearHelper.lua:833>

Locals: self = MyExampleCheckButton {
0 = <userdata>
text = MyExampleCheckButtonText {
}
}
event = "LeftButton"
arg1 = false
(*temporary) = nil
(*temporary) = MyExampleCheckButton {
0 = <userdata>
text = MyExampleCheckButtonText {
}
}
(*temporary) = "attempt to call method 'GetChecked' (a nil value)"
Do you have any clue ?
  Reply With Quote
08-04-16, 09:27 AM   #2
syncrow
A Flamescale Wyrmkin
 
syncrow's Avatar
AddOn Author - Click to view addons
Join Date: Jul 2014
Posts: 149
change:
Lua Code:
  1. local checkButton = CreateFrame("Button", name, UIParent, template)

into:

Lua Code:
  1. local checkButton = CreateFrame("CheckButton", name, UIParent, template)
__________________
  Reply With Quote
08-04-16, 10:10 AM   #3
Marsgames
An Aku'mai Servant
 
Marsgames's Avatar
Join Date: Jul 2016
Posts: 33
That work, thanks sir
  Reply With Quote
08-04-16, 12:23 PM   #4
Seerah
Fishing Trainer
 
Seerah's Avatar
WoWInterface Super Mod
Featured
Join Date: Oct 2006
Posts: 10,745
Just to clarify (and for others reading), nothing was changed or deprecated. The :GetChecked() method doesn't exist on a normal button object. You just needed to create the correct type of widget.
__________________
"You'd be surprised how many people violate this simple principle every day of their lives and try to fit square pegs into round holes, ignoring the clear reality that Things Are As They Are." -Benjamin Hoff, The Tao of Pooh

  Reply With Quote

WoWInterface » Developer Discussions » General Authoring Discussion » GetChecked() deprecated ?

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