|
10-11-19, 08:24 PM | #1 |
dynamic key bindings with SecureHandlers
Hey all,
I'm new here, and new to writing WoW addons and a bit at a loss as to how to progress with my mod. To start with, the functionality I am trying to achieve is as follows: The idea is that I want to be able to easily cast any Shaman totem with 3 key strokes. 1) Starting state: keys 1 through to 9 are bound as normally to actionbar 1 2) clicking '/click ElementBinder' in a macro rebinds keys 1 to 4 to represent the 4 totem elements (1: Earth, 2: Fire, 3: Water, 4: Air) 3) Now, pressing any of these overridden keys further overrides them to represent individual Totems to cast,(1: cast Earthbind Totem, 2: cast Strength of Earth, etc). 4) After any Totem is cast, clear all existing bindings: keys 1 through to 9 are bound as normally to actionbar 1 So for Example: Pressing F > 1 > 2 casts Strength of Earth totem Pressing F > 1 > 1 casts Earthbind Totem Pressing F > 2 > 1 casts Searing Totem Pressing F > 3 > 1 casts Healing Stream Totem etc .. So far I have been using SecureHandlers to enable this to work in combat - and it does! However, I have no way to clear the overridden bindings once a Totem is cast and I am looking for any help/suggestions to achieve this! Here is some code snippets. Macro to initiate the functionality: Code:
/click ElementBinder Code:
local element_binder = CreateFrame("BUTTON", "ElementBinder", UIParent, "SecureHandlerClickTemplate"); element_binder:SetAttribute("_onclick", [=[ if button == "LeftButton" then self:SetBindingClick(true, "1", "EarthBtn") self:SetBindingClick(true, "2", "FireBtn") -- etc for water and air end ]=]); local earth_btn = CreateFrame("BUTTON", "EarthBtn", element_binder, "SecureHandlerClickTemplate") earth_btn:SetAttribute("_onclick", [=[ if button == "LeftButton" then self:SetBindingSpell(true, "1", "Earthbind Totem") self:SetBindingSpell(true, "2", "Strength of Earth Totem") -- etc for the rest of the earth totems end ]=])
Also, is there another way of initiating the original 'click' on the first handler other than through a macro? Any ideas? Thanks in advance! |
|
10-11-19, 10:21 PM | #2 |
There's a distinction with the terminology you're using. There's no such thing as "clearing" a binding you have set back to what it was. When you set a key to something, the previous setting is lost. Clearing a binding is to remove all actions from it. There is also no inherent default to any key, you either need to remember the default before changing a single binding or use LoadBindings(0) to reset ALL keys.
If your intention is to "reset" 1-4 back to the action buttons, just set them to the action buttons. SetBinding and BindingID are what you're looking for. If I recall correctly, frame:ClearBindings() only removes the frame from any registered bindings, the actual binding is not changed.
__________________
Last edited by Kanegasi : 10-11-19 at 10:26 PM. |
|
10-20-19, 03:20 AM | #3 | |
Thanks for your reply anyway! |
||
10-11-19, 10:31 PM | #4 |
It seems like a feature in my IGAS_UI/ActionBar, you can find an example at the end of the page. Well, maybe not, you require two level key binding.
Back to the question, I have an example for you Lua Code:
Run it with WowLua or my Cube or whatever in the game, then press F-1-1, F-1-2, F-2-1 to see the result, the log should show how the code works. I have no high level shaman, so I use other macro for examples. |
|
10-20-19, 03:15 AM | #5 | |
|
||
10-20-19, 06:03 AM | #6 | |
1. RestrictedInfrastructure.lua: Wrap the normal frame to secure handler, and some api for secure using. 2. RestrictedEnvironment.lua: the restricted environment to execute the secure snippets and some api. 3. RestrictedFrames.lua: the secure handler methods that can be used in secure snippets. 4. RestrictedExecution.lua: the execution of the secure snippets, the core part is every secure handler(the wrapper of the frame) has a standalone environment, that's why I always create a manager to process the secure snippets, so all processed in one environment. 5. SecureHandlers.lua: All for secure handler's events, the best in it is the SecureHandlerWrapScript, so I can use manager to wrap all secure frame's actions. 6. SecureTemplates.lua: the template for secure frames, the common is the SecureActionButtonTemplate, used for action button. 7. SecureGroupHeaders.lua: for the raid panel, it's a hard topic, I use it for my secure panel lib, so they can refresh well in the combat no matter player join or leave. 8. SecureStateDriver.lua: It's the best system event trigger(although only support marco conditions) to force the secure frames refreshing during the combat. I have practiced those features in my own raid panel, container, action bar addon(no dependencies), some features are never used in other addons, the secure system is a gold mine but hard for digging. If your are interesting, I have some post in this forum talked about the usages of the secure frames, you may learn some tricks from them. |
||
10-14-19, 04:55 PM | #7 |
if you use SetOverrideBindingClick and ClearOverrideBindings you'll get your temporary bindings
example of use: https://github.com/mooreatv/AuctionD....lua#L145-L151 |
|
10-20-19, 03:16 AM | #8 | |
|
||
WoWInterface » Developer Discussions » Lua/XML Help » dynamic key bindings with SecureHandlers |
«
Previous Thread
|
Next Thread
»
|
Display Modes |
Switch to Linear Mode |
Hybrid Mode |
Switch to Threaded Mode |
|
|