Quantcast
SecureActionButton with key down, mouse up - WoWInterface
Thread Tools Display Modes
05-28-21, 04:59 PM   #1
DahkCeles
A Theradrim Guardian
 
DahkCeles's Avatar
AddOn Author - Click to view addons
Join Date: Jun 2020
Posts: 62
SecureActionButton with key down, mouse up

I just spend quite a long time finding a way to securely mimic the console variable ActionButtonUseKeyDown, so that custom action bars (beyond the default UI range) can securely respond on key-press (down) and mouse-release (up).

A lot of solutions that I tried simply didn't work. Mouse and keybuttons both up: easy. Mouse and keybuttons both down: easy. For the default action bar ranges: easy. But for actions beyond the multi-action-bar range? Lots of things I tried wouldn't work.


I think I've found a solution, and just want to post it here for three reasons:
(a) Can anyone think of a way this is going to fail?
(b) Am I overthinking it... is there an easier way to do this?
(c) If not, maybe someone else will find this useful?


Lua Code:
  1. -- create a typical action button... but also inherit SecureHandlerBaseTemplate
  2. local button = CreateFrame("CheckButton", "myActionButton80", nil, "SecureActionButtonTemplate,SecureHandlerBaseTemplate")
  3. button:SetAttribute("type", "action")
  4. button:SetAttribute("action", 80)
  5.  
  6. -- give it a keybinding, and make it respond to mouse clicks
  7. SetBinding("SHIFT-Q", "CLICK myActionButton80:Button31")
  8. button:RegisterForClicks("AnyUp", "Button31Down")
  9.  
  10. -- here is the magic so that releasing the keybind will be ignored
  11. button:WrapScript(button, "OnClick", [=[
  12.     -- self, button, down
  13.     if (down) then
  14.         self:SetAttribute("type31", "action")
  15.     else
  16.         self:SetAttribute("type31", "")
  17.     end
  18. ]=])

Last edited by DahkCeles : 05-28-21 at 05:02 PM.
  Reply With Quote

WoWInterface » Developer Discussions » Lua/XML Help » SecureActionButton with key down, mouse up

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