WoWInterface

WoWInterface (https://www.wowinterface.com/forums/index.php)
-   Lua/XML Help (https://www.wowinterface.com/forums/forumdisplay.php?f=16)
-   -   Run a slash command from a button (https://www.wowinterface.com/forums/showthread.php?t=58799)

Walkerbo 06-17-21 08:08 PM

Run a slash command from a button
 
Hi all

I currently have a macro to toggle the frame stack, I wish to build a button that will run /fstack rather than using a macro.

Further, I wish to have a button that will /logout: I have read that ForceLogout() is protected so I cannot just add it to a button onClick function.

Is there a way that I can build a button that will run a slash command?

Fizzlemizz 06-17-21 08:44 PM

Lua Code:
  1. local f1 = CreateFrame("Button", nil, UIParent, "SecureActionButtonTemplate, UIPanelButtonTemplate")
  2. f1:SetSize(80, 30)
  3. f1:SetPoint("CENTER")
  4. f1:SetText("Logout")
  5. f1:SetAttribute("type", "macro")
  6. f1:SetAttribute("macrotext", "/logout")
  7.  
  8. local f2 = CreateFrame("Button", nil, UIParent, "UIPanelButtonTemplate")
  9. f2:SetSize(80, 30)
  10. f2:SetPoint("TOP", f1, "BOTTOM")
  11. f2:SetText("FStack")
  12. f2:SetScript("OnClick", function(self)
  13.     if not FrameStackTooltip_Toggle then
  14.         LoadAddOn("Blizzard_DebugTools")
  15.     end
  16.     FrameStackTooltip_Toggle()
  17. end)

Walkerbo 06-17-21 10:30 PM

Hi Fizzlemizz

They both work flawlessly, thank you so much for your help.


All times are GMT -6. The time now is 04:25 PM.

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