Quantcast
Run a slash command from a button - WoWInterface
Thread Tools Display Modes
06-17-21, 08:08 PM   #1
Walkerbo
A Flamescale Wyrmkin
 
Walkerbo's Avatar
AddOn Author - Click to view addons
Join Date: Oct 2010
Posts: 139
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?
__________________
"As someone once told me, frames are just special types of tables, and tables are special types of pointers."
Fizzlemizz
  Reply With Quote
06-17-21, 08:44 PM   #2
Fizzlemizz
I did that?
 
Fizzlemizz's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Dec 2011
Posts: 1,429
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)
__________________
Fizzlemizz
Maintainer of Discord Unit Frames and Discord Art.
Author of FauxMazzle, FauxMazzleHUD and Move Pad Plus.
  Reply With Quote
06-17-21, 10:30 PM   #3
Walkerbo
A Flamescale Wyrmkin
 
Walkerbo's Avatar
AddOn Author - Click to view addons
Join Date: Oct 2010
Posts: 139
Hi Fizzlemizz

They both work flawlessly, thank you so much for your help.
__________________
"As someone once told me, frames are just special types of tables, and tables are special types of pointers."
Fizzlemizz
  Reply With Quote

WoWInterface » Developer Discussions » Lua/XML Help » Run a slash command from a button

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