Thread Tools Display Modes
10-28-22, 03:46 PM   #1
Walkerbo
A Cobalt Mageweaver
 
Walkerbo's Avatar
AddOn Author - Click to view addons
Join Date: Oct 2010
Posts: 233
Fix run a slash command from a button

Hi all

I had a button that ran a slash command;
Lua Code:
  1. local NewbDevBoxButtonFrameREHackButton =
  2.     CreateFrame(
  3.     "Button",
  4.     "NewbDevBoxButtonFrameREHackButton",
  5.     NewbDevBoxButtonFrame,
  6.     "SecureActionButtonTemplate, GameMenuButtonTemplate"
  7. )
  8. NewbDevBoxButtonFrameREHackButton:SetSize(NumberList.actionButtonWidth, NumberList.actionButtonHeight)
  9. NewbDevBoxButtonFrameREHackButton:SetText(TextStringList.btnREHackButton)
  10. NewbDevBoxButtonFrameREHackButton:SetNormalFontObject(TextDimensionList.buttonFont)
  11. NewbDevBoxButtonFrameREHackButton:SetHighlightFontObject(TextDimensionList.buttonFont)
  12. NewbDevBoxButtonFrameREHackButton:SetAttribute("type", "macro")
  13. NewbDevBoxButtonFrameREHackButton:SetAttribute("macrotext", "/hack")
This was broken on the launch of pre-patch.
How do I get this working again?
__________________
"As someone once told me, frames are just special types of tables, and tables are special types of pointers."
Fizzlemizz
  Reply With Quote
10-28-22, 03:58 PM   #2
Xrystal
nUI Maintainer
 
Xrystal's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Feb 2006
Posts: 5,931
What error does it report ?
Which of the lines does it say is/are the problem ?

It's possible the templates you are using no longer exist so you might have to identify an alternative if that is the case.
__________________


Characters:
Gwynedda - 70 - Demon Warlock
Galaviel - 65 - Resto Druid
Gamaliel - 61 - Disc Priest
Gwynytha - 60 - Survival Hunter
Lienae - 60 - Resto Shaman
Plus several others below level 60

Info Panel IDs : http://www.wowinterface.com/forums/s...818#post136818
  Reply With Quote
10-28-22, 04:08 PM   #3
Walkerbo
A Cobalt Mageweaver
 
Walkerbo's Avatar
AddOn Author - Click to view addons
Join Date: Oct 2010
Posts: 233
Sorry, I should have said.

I get no errors at all.
The button template still works for other buttons such as the reload UI button.
__________________
"As someone once told me, frames are just special types of tables, and tables are special types of pointers."
Fizzlemizz
  Reply With Quote
10-28-22, 05:00 PM   #4
Fizzlemizz
I did that?
 
Fizzlemizz's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Dec 2011
Posts: 1,877
Is Hack (or whatever /hack is supposed to call), still in your AddOns, still enabled, ...
__________________
Fizzlemizz
Maintainer of Discord Unit Frames and Discord Art.
Author of FauxMazzle, FauxMazzleHUD and Move Pad Plus.
  Reply With Quote
10-28-22, 05:01 PM   #5
Xrystal
nUI Maintainer
 
Xrystal's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Feb 2006
Posts: 5,931
Just copied your code and changed it to work on my game and the following works... hopefully it may offer clues as to what might be making it not work for you.

I parented my version of the frame to UIParent as I don't have a frame to parent it to in my testaddon. I then set it's point in relation to it's parent. I then hardcoded the size, text, fonts and the macro to use.

Lua Code:
  1. local NewbDevBoxButtonFrameREHackButton =
  2.     CreateFrame(
  3.     "Button",
  4.     "NewbDevBoxButtonFrameREHackButton",
  5.     UIParent,
  6.     "SecureActionButtonTemplate, GameMenuButtonTemplate"
  7. )
  8. NewbDevBoxButtonFrameREHackButton:SetPoint("CENTER")
  9. NewbDevBoxButtonFrameREHackButton:SetSize(30, 30)
  10. NewbDevBoxButtonFrameREHackButton:SetText("Text")
  11. NewbDevBoxButtonFrameREHackButton:SetNormalFontObject(GameFontNormal)
  12. NewbDevBoxButtonFrameREHackButton:SetHighlightFontObject(GameFontWhite)
  13. NewbDevBoxButtonFrameREHackButton:SetAttribute("type", "macro")
  14. NewbDevBoxButtonFrameREHackButton:SetAttribute("macrotext", "/sit")
__________________


Characters:
Gwynedda - 70 - Demon Warlock
Galaviel - 65 - Resto Druid
Gamaliel - 61 - Disc Priest
Gwynytha - 60 - Survival Hunter
Lienae - 60 - Resto Shaman
Plus several others below level 60

Info Panel IDs : http://www.wowinterface.com/forums/s...818#post136818
  Reply With Quote
10-28-22, 06:35 PM   #6
Walkerbo
A Cobalt Mageweaver
 
Walkerbo's Avatar
AddOn Author - Click to view addons
Join Date: Oct 2010
Posts: 233
@Fizzlemizz
Yes Hack is an addon and I have it operational, and I have tested it using its slash command in the chat box and I can confirm that it does work.

@Xrystal
Thanks for your code, however, I still get the same results, I don't sit when I click your button
__________________
"As someone once told me, frames are just special types of tables, and tables are special types of pointers."
Fizzlemizz
  Reply With Quote
10-28-22, 06:39 PM   #7
Fizzlemizz
I did that?
 
Fizzlemizz's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Dec 2011
Posts: 1,877
Register the button for AnyUp and AnyDown clicks.
__________________
Fizzlemizz
Maintainer of Discord Unit Frames and Discord Art.
Author of FauxMazzle, FauxMazzleHUD and Move Pad Plus.

Last edited by Fizzlemizz : 10-28-22 at 06:42 PM.
  Reply With Quote
10-28-22, 07:20 PM   #8
Xrystal
nUI Maintainer
 
Xrystal's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Feb 2006
Posts: 5,931
Originally Posted by Walkerbo View Post
@Fizzlemizz
Yes Hack is an addon and I have it operational, and I have tested it using its slash command in the chat box and I can confirm that it does work.

@Xrystal
Thanks for your code, however, I still get the same results, I don't sit when I click your button

Weird, my character sat as soon as I clicked the button.

Although I only had the bugcatching addons active at the time in case another addon is interfering.
__________________


Characters:
Gwynedda - 70 - Demon Warlock
Galaviel - 65 - Resto Druid
Gamaliel - 61 - Disc Priest
Gwynytha - 60 - Survival Hunter
Lienae - 60 - Resto Shaman
Plus several others below level 60

Info Panel IDs : http://www.wowinterface.com/forums/s...818#post136818
  Reply With Quote
10-28-22, 07:37 PM   #9
Fizzlemizz
I did that?
 
Fizzlemizz's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Dec 2011
Posts: 1,877
It depends on your setting for the CVar "ActionButtonUseKeyDown"
__________________
Fizzlemizz
Maintainer of Discord Unit Frames and Discord Art.
Author of FauxMazzle, FauxMazzleHUD and Move Pad Plus.
  Reply With Quote
10-29-22, 03:54 PM   #10
Walkerbo
A Cobalt Mageweaver
 
Walkerbo's Avatar
AddOn Author - Click to view addons
Join Date: Oct 2010
Posts: 233
@Fizzlemizz

Adding in the register for clicks worked!

It is amazing when I think that I am starting to get a handle on coding something like this pre-patch just comes along and slaps me down again.

I would be lost without the help I get from this community.

Thanks all
__________________
"As someone once told me, frames are just special types of tables, and tables are special types of pointers."
Fizzlemizz
  Reply With Quote
10-29-22, 05:17 PM   #11
SDPhantom
A Pyroguard Emberseer
 
SDPhantom's Avatar
AddOn Author - Click to view addons
Join Date: Jul 2006
Posts: 2,326
Why not simplify it and not make it a SecureActionButton? With some digging around in Hack's code, you can find their slash handler.

This happens to be at line 183 of Hack.lua
Code:
SlashCmdList['HACKSLASH'] =
	function(name)
		if name == '' then
			Hack.Toggle()
		else
			Hack.Run(name)
		end
	end
You could just call SlashCmdList["HACKSLASH"](""), but further digging shows the table Hack is a global, meaning you can call Hack.Toggle() directly.
Lua Code:
  1. local NewbDevBoxButtonFrameREHackButton =
  2.     CreateFrame(
  3.     "Button",
  4.     "NewbDevBoxButtonFrameREHackButton",
  5.     NewbDevBoxButtonFrame,
  6.     "GameMenuButtonTemplate"
  7. )
  8. NewbDevBoxButtonFrameREHackButton:SetSize(NumberList.actionButtonWidth, NumberList.actionButtonHeight)
  9. NewbDevBoxButtonFrameREHackButton:SetText(TextStringList.btnREHackButton)
  10. NewbDevBoxButtonFrameREHackButton:SetNormalFontObject(TextDimensionList.buttonFont)
  11. NewbDevBoxButtonFrameREHackButton:SetHighlightFontObject(TextDimensionList.buttonFont)
  12. NewbDevBoxButtonFrameREHackButton:SetScript("OnClick",function() if Hack then Hack.Toggle() end end)
__________________
WoWInterface AddOns
"All I want is a pretty girl, a decent meal, and the right to shoot lightning at fools."
-Anders (Dragon Age: Origins - Awakening)
  Reply With Quote
10-30-22, 08:16 AM   #12
Uitat
A Chromatic Dragonspawn
 
Uitat's Avatar
AddOn Author - Click to view addons
Join Date: May 2011
Posts: 162
my solution

in project deranjata i came up wit this bit o code, it may help you
Lua Code:
  1. function AutoStart()--[[name this whatever your button will activate]]--
  2.         local editbox=ChatEdit_ChooseBoxForSend(DEFAULT_CHAT_FRAME);--Get an editbox
  3.         ChatEdit_ActivateChat(editbox);--  Show the editbox
  4.         editbox:SetText("/der");--[[ Command goes here]]
  5.         ChatEdit_OnEnterPressed(editbox);--[[ Process command and hide (runs ChatEdit_SendText() and ChatEdit_DeactivateChat() respectively)]]--
  6. end
__________________
  Reply With Quote

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


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