SecureActionButtonTemplate with macrotext attribute not working
None of my secure buttons with macrotext attribute are working on PTR 10.x
In the main XML file (MyAddon.xml): Code:
<Frame name="npcm_frameMain" frameStrata="BACKGROUND" virtual="false" hidden="true" resizable="true" parent="UIParent" inherits="SecureHandlerStateTemplate"> In the main lua file (MyAddon.lua): Lua Code:
Nothing happens when the button is clicked (and no error message nor warning about blocked action). :( Thank you for your help. |
You still need to call Button:RegisterForClicks() for the OnClick handler to work.
It's also good practice to make sure Frame:EnableMouse() or Frame:SetMouseClickEnabled() is set. Frame:EnableMouse() is a legacy function that controls both clicks and mouseover while Frame:SetMouseClickEnabled() and Frame:SetMouseMotionEnabled() individually control each of their respective features. On a side note, you don't need a SecureActionButton to send /sit. It's processed as an emote using the "SIT" and DoEmote() is not protected. You can run it as DoEmote("SIT"). |
I understand the value of following good practices, but as far as I know a frame defined as "button" handles mouseClick by default.
Anyhow, I tested with button:SetMouseClickEnabled() without success. PostClick script works, so the button is active and correctly responds to clicks. The problem comes from: Lua Code:
Concerning the macro itself (/sit), it's just a basic example used in my tests. As the buttons in part of my addon NPCsMarker, the real macro is something like "/wm 1" or "/cwm 1" to place or clear ground markers. |
Could it simply be a case of some script functionality not being enabled on the alpha/beta whatever 10 is atm?
|
You still didn't address Button:RegisterForClicks(), which tells the button what clicks to look for (Left, Right, Middle, etc.) If you don't register any, it won't know what to listen for and therefore won't work.
This is a separate function from just telling a frame it should react to mouse events. |
To be sure, I just tested with Button:RegisterForClicks() without success.
Lua Code:
|
Here's the OnClick handler on PTR.
Lua Code:
Basically, the handler is looking for either an up or down click event specifically according to how the ActionButtonUseKeyDown CVar is set. If it never gets the matching click event, the code never runs. It's probably a good idea to register both up and down click events for every button you intend to respond to. If you don't care about registering individual buttons, you can use "AnyUp" and "AnyDown". Quote:
Lua Code:
This defines type "worldmarker" with parameters "marker" and "action". As with any other attribute fetched by SecureButton_GetModifiedAttribute(), you can append the attribute name (not the value) with a number representing the mouse button to bind to (1=Left, 2=Right, 3=Middle, etc.) |
Interesting, SDPhantom. Thank you.
I have to say that I'm not sure how to adapt my code based on what you found. As a reminder, I use the following basic code for a button with a macrotext attribute. It works fine on WoW 9.x: Lua Code:
Also, I believe the code you found concerns the raid markers (placed on units) and not the ground markers (placed on... the ground :D). |
Based on the example on this page
https://wowpedia.fandom.com/wiki/Sec...ButtonTemplate Have you tried changing type and macrotext to type1 and macrotext1 for left button click as these are attributes as SDPhantom mentioned. Although, I think ( not 100% sure ), that left button is default so maybe macrotext with no number is treated as macrotext1 :shrugs: Just tested this version of your code using your original sit test on the PTR just now ( there was a big update ) and it worked Lua Code:
|
Just copy/pasted your code Xrystal (after 2 PTR updates) but if it correctly print the PostClick, the macro (/sit or /abs) wasn't executed.
So, I'm a little bit confused... and still standing ;) Are you able to sit down with the code you posted? Or maybe we'll have another PTR server update in Europe. |
Quote:
Code:
button:RegisterForClicks("LeftButtonUp", "RightButtonUp") Code:
button:RegisterForClicks("LeftButtonUp", "LeftButtonDown", "RightButtonUp", "RightButtonDown") Code:
button:RegisterForClicks("AnyUp", "AnyDown") Quote:
RaidTargets are set by SetRaidTarget() while WorldMarkers have PlaceRaidMarker() and ClearRaidMarker(). (WoWPedia doesn't have an API page on the WorldMarker functions) Here's an example of your button configured for this. Lua Code:
Quote:
|
Quote:
Yes, I was able to sit down on the 10.0 PTR with that code, and the print statement was displayed as well. |
Quote:
I have a US account despite being in the UK and I had an update this morning ( UK time ) but my brother who has a UK account hasn't noticed any dragonflight changes on his PTR. I wonder if there is some sort of difference between the two regions :ponders: |
OK, I'm now able to /sit :banana:
SDPhantom is right: both up and down listener are required for SecureActionButtonTemplate. EDIT: As PostClick debugging is now printed twice, I had to add a test before performing PostClick actions. This is the actual /sit button. I'll test with ground markers this evening and keep you informed. Lua Code:
|
OK, placing Ground Markers works fine.
Thank you SDPhantom, you saved my addon :) I have a specific icon to delete placed ground marker, so I don't use the right-click on marker's button. But I used shift to trigger another macro (insert marker's icon in the opened chat box, but "/sit" to simplify in the following example: Lua Code:
This code is no longer working. Can you tell how to add a shift-clic macro to your code? |
try the shift- on the type statement
As in btn:SetAttribute("shift-type1", "macro") |
OK.
I still have an annoying problem: as the up and down mouse button are registered, it triggers the action twixe. I can handle this on the PostClick script with the third argument, but I don't know how to handle the main action - the one defined as a shit-click macro. For example, line #6 is executed twice :( Lua Code:
BTW, it's for NPCsMarker, a RP addon. |
Quote:
So, all is OK. Thank you all :) |
I had a similar confusing situation that was due to having a different setting of cvar `ActionButtonUseKeyDown` on retail vs beta. If `ActionButtonUseKeyDown` is off then `AnyDown` will not work at all.
|
All times are GMT -6. The time now is 08:05 AM. |
vBulletin © 2024, Jelsoft Enterprises Ltd
© 2004 - 2022 MMOUI