Thread Tools Display Modes
07-14-15, 03:11 PM   #1
gempir
A Black Drake
 
gempir's Avatar
AddOn Author - Click to view addons
Join Date: Jun 2015
Posts: 84
Executing chat commands without SecureActionButtonTemplate

So I have 3 buttons in my Interface which are supposed to do stuff like Readycheck, clear worldmarkers and rolecheck.

This is my code http://pastebin.com/aU0XKXE0

The problem is basicly

Lua Code:
  1. local frame = CreateFrame("Button", btnName, gWorldmarkers, "SecureActionButtonTemplate");

That SecureActionButtonTemplate is protected and can't be used in Combat. But that sadly means that the frame which the buttons are parented to is also impossible to hide() or show() in combat.

My question is how do I execute chat commands such as /readycheck

I know rolecheck has a function but I couldn't find any for clearing all worlmarkers or readychecks.
  Reply With Quote
07-14-15, 05:32 PM   #2
SDPhantom
A Pyroguard Emberseer
 
SDPhantom's Avatar
AddOn Author - Click to view addons
Join Date: Jul 2006
Posts: 2,324
If the command you're running is a secure command, you simply can't use it without the secure templates. Since world markers are secure actions, you're pretty much out of luck there. Ready checks can be initiated by calling DoReadyCheck().
__________________
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)

Last edited by SDPhantom : 07-14-15 at 05:39 PM.
  Reply With Quote
07-14-15, 05:49 PM   #3
Banknorris
A Chromatic Dragonspawn
 
Banknorris's Avatar
AddOn Author - Click to view addons
Join Date: Oct 2014
Posts: 153
For some commands you can
Code:
local editbox = ChatEdit_ChooseBoxForSend(DEFAULT_CHAT_FRAME)
ChatEdit_ActivateChat(editbox)
editbox:SetText("/readycheck") --not sure if this particular command requires a hardware click or not
ChatEdit_OnEnterPressed(editbox)
I do this when I want my addon to use a slash command of another addon.
__________________
"In this world nothing can be said to be certain, except that fractional reserve banking is a Ponzi scheme and that you won't believe it." - Mandrill
  Reply With Quote
07-14-15, 06:16 PM   #4
SDPhantom
A Pyroguard Emberseer
 
SDPhantom's Avatar
AddOn Author - Click to view addons
Join Date: Jul 2006
Posts: 2,324
Originally Posted by Banknorris View Post
For some commands you can
Code:
local editbox = ChatEdit_ChooseBoxForSend(DEFAULT_CHAT_FRAME)
ChatEdit_ActivateChat(editbox)
editbox:SetText("/readycheck") --not sure if this particular command requires a hardware click or not
ChatEdit_OnEnterPressed(editbox)
I do this when I want my addon to use a slash command of another addon.
This can only be done with insecure commands. Attempting to run this on a secure command will raise an action blocked error. As for the ready check, if you have a way to call the function directly, which I explained how previously, there's no need to waste CPU cycles processing string input into a command to eventually run the function anyway. Even so, this example is extremely harsh in which it hijacks a user control to do so.

If you can find no direct access to the function used by a slash command, you can access it by indexing the SlashCmdList table. Note this is only for a last resort. Do NOT use this method if you have direct access to a function.

Code:
SlashCmdList["COMMAND_TOKEN"]("arguments");
Note you need to do some research into the UI or addon code to find out what the token for a command is. If you want to be lazy, you can access hash_SlashCmdList with additional hacking, but this is guaranteed to work on all locales.

As a final notice, neither this nor any other code would allow running secure commands. There's just no way around that.
__________________
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)

Last edited by SDPhantom : 07-14-15 at 06:18 PM.
  Reply With Quote
07-15-15, 03:47 AM   #5
gempir
A Black Drake
 
gempir's Avatar
AddOn Author - Click to view addons
Join Date: Jun 2015
Posts: 84
Well that's sad.

Is my theory correct that frames parented to SecureActions can't be hidden or shown?

That's my main problem. I don't really want to make them available in combat, but the frame itself should be.
  Reply With Quote
07-15-15, 04:19 AM   #6
elcius
A Cliff Giant
AddOn Author - Click to view addons
Join Date: Sep 2011
Posts: 75
You just need to hide them using another secure button.
  Reply With Quote
07-15-15, 04:47 AM   #7
gempir
A Black Drake
 
gempir's Avatar
AddOn Author - Click to view addons
Join Date: Jun 2015
Posts: 84
Originally Posted by elcius View Post
You just need to hide them using another secure button.
Wait, but doesn't that mean that the button wouldn't work in combat? I'm confused
  Reply With Quote
07-15-15, 06:08 AM   #8
elcius
A Cliff Giant
AddOn Author - Click to view addons
Join Date: Sep 2011
Posts: 75
secure actions buttons can be used in combat, that is what they were designed to do.
  Reply With Quote
07-15-15, 06:59 AM   #9
gempir
A Black Drake
 
gempir's Avatar
AddOn Author - Click to view addons
Join Date: Jun 2015
Posts: 84
Originally Posted by elcius View Post
secure actions buttons can be used in combat, that is what they were designed to do.
Hmm, but my other buttons work in Combat without the SecureActionButton template

Here is what I do for my buttons:

Lua Code:
  1. button:SetScript("OnMouseDown", function(self, button)
  2.             something:show()
  3.       end)
Every button works in combat, except the button which toggles the frame with the worldmarkers, readycheck and such
  Reply With Quote
07-15-15, 11:16 AM   #10
Seerah
Fishing Trainer
 
Seerah's Avatar
WoWInterface Super Mod
Featured
Join Date: Oct 2006
Posts: 10,860
Do your other buttons perform non-secure actions?
__________________
"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
07-15-15, 12:10 PM   #11
gempir
A Black Drake
 
gempir's Avatar
AddOn Author - Click to view addons
Join Date: Jun 2015
Posts: 84
Originally Posted by Seerah View Post
Do your other buttons perform non-secure actions?
1 just changes some variables the other opens skada. So i guess they are non-secure.

I just don't get why the button to open a frame has to be secure aswell. I mean the button doesn't actually perform a secure-action.

It just shows 3 buttons that perform secure actions onclick
  Reply With Quote
07-15-15, 12:36 PM   #12
Lombra
A Molten Giant
 
Lombra's Avatar
AddOn Author - Click to view addons
Join Date: Nov 2006
Posts: 554
Originally Posted by gempir View Post
I just don't get why the button to open a frame has to be secure aswell. I mean the button doesn't actually perform a secure-action.

It just shows 3 buttons that perform secure actions onclick
Showing or hiding a secure frame is very much a secure action.
__________________
Grab your sword and fight the Horde!
  Reply With Quote
07-15-15, 12:39 PM   #13
gempir
A Black Drake
 
gempir's Avatar
AddOn Author - Click to view addons
Join Date: Jun 2015
Posts: 84
Thanks! That was my question.

Any any how to make this

Lua Code:
  1. button:SetScript("OnMouseDown", function(self, button)
  2.             something:show()
  3.       end)

with a Secure Action Button Template?
  Reply With Quote
07-15-15, 02:12 PM   #14
Lombra
A Molten Giant
 
Lombra's Avatar
AddOn Author - Click to view addons
Join Date: Nov 2006
Posts: 554
Originally Posted by gempir View Post
Thanks! That was my question.

Any any how to make this

Lua Code:
  1. button:SetScript("OnMouseDown", function(self, button)
  2.             something:show()
  3.       end)

with a Secure Action Button Template?
I'm a bit confused as to what you want to do, exactly, but I think you should be able to do just that.

Leatrix had probably got the right idea, though. Except for clearing world markers which should be a protected action.

Can you explain, without involving secure frames, what you're trying to do?
__________________
Grab your sword and fight the Horde!
  Reply With Quote
07-15-15, 02:45 PM   #15
Lombra
A Molten Giant
 
Lombra's Avatar
AddOn Author - Click to view addons
Join Date: Nov 2006
Posts: 554
Oh, really? Would never have guessed!
__________________
Grab your sword and fight the Horde!
  Reply With Quote
07-16-15, 01:45 AM   #16
gempir
A Black Drake
 
gempir's Avatar
AddOn Author - Click to view addons
Join Date: Jun 2015
Posts: 84
My goal was to create a frame that can be toggled with a button.

On that frame are 3 buttons who each have seperate functions. (Clear Worldmarkers, Readycheck, Rolecheck)

The 3 buttons are parented to the frame so that once the frame is hidden so are the buttons, this raises the need for a secure action button for toggling the frame. Otherwise I can't toggle the frame in-combat.

Leatrix solution should work fine, i'll try it later.

Thanks :-)
  Reply With Quote

WoWInterface » Developer Discussions » Lua/XML Help » Executing chat commands without SecureActionButtonTemplate


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