View Single Post
02-16-15, 05:37 PM   #21
Phanx
Cat.
 
Phanx's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2006
Posts: 5,617
Originally Posted by Malsomnus View Post
Lua Code:
  1. f.btn:SetScript ('PostClick', function()
  2.   C_Timer.After(1, function ()
  3.     PlayerTalentFrameTalentsLearnButton:GetScript("OnClick")(PlayerTalentFrameTalentsLearnButton)
  4.   end)  
  5. end)
You should factor that C_Timer callback out into a separate function so you're not re-creating it over and over every time you click your button:

Lua Code:
  1. local function clickLearnButton()
  2.   PlayerTalentFrameTalentsLearnButton:GetScript("OnClick")(PlayerTalentFrameTalentsLearnButton)
  3. end
  4. f.btn:SetScript ('PostClick', function()
  5.   C_Timer.After(1, clickLearnButton)  
  6. end)

You can probably also just do:

Lua Code:
  1. PlayerTalentFrameTalentsLearnButton:Click()
__________________
Retired author of too many addons.
Message me if you're interested in taking over one of my addons.
Don’t message me about addon bugs or programming questions.
  Reply With Quote