I want to make a ('secure'-)frame which is only click-enabled when the mouse hovers over it while the [alt] key is held down. When the [alt] key is not held down it should be possible to click through the frame. I also want it to be possible to move the frame based on a user defined variable which locks or unlocks the position of the frame.
Furthermore I want the frame to be kind of 'highlighted' when the mouse hovers over it while the [alt] key is held down, and nothing to happen when the mouse hovers over the frame without the [alt] key held down.
The purpose of the frame, is to show information to the player and for the player to be able to target himself with it.
I am pretty new to this 'SecureActionButtonTemplate'-stuff, but I have come up with this piece of code after reading up on it around the net:
SimpleHUD["player"].clickable_Frame = CreateFrame("Button", "player_clickable_Frame", UIParent, "SecureActionButtonTemplate")
if IsAltKeyDown() then
if IsAltKeyDown() then
This works almost the way I want, except that:
- It is not possible to click through the frame when the [alt] key is not held down, it also highlights my character even though the [alt] key isn't activated.
- The frame isn't highlighted when the mouse already hovers over the frame and the [alt] key is pressed.
I think I might be able to fix the frame-highlighting problem, but I can't seem to find a solution to the "click-through" problem.
I have unsuccessful messed around with:
SimpleHUD["player"].clickable_Frame:Disable() / Enable()
SimpleHUD["player"].clickable_Frame:EnableMouse(false) / EnableMouse(true)
My conclusion so far:
I think I have to disable and enable the 'Attribute'-stuff somehow based on whether the [alt] key is activated or not. But I don't know how to reset or disable these 'SetAttribute'-things in a proper way, and I wouldn't be surprised if this really isn't the solution.
I'm about 99.99% certain you can't do it that way, especially while in combat. You could use a state driver to show the unit frame only while Alt was pressed. If you want something to always be visible, attach the visible UI objects to the state driver instead of the unit frame. See my addon ImprovedTotemFrame for a simple example of using a state driver to automatically hide/show a secure frame using macro conditions.
HUURAAY!!! I made it work, thank you so much for helping out it was great inspiration :)
- create a Frame with 'SecureHandlerStateTemplate' as template.
- setup statedriver and attribute to show and hide the frame based on the [alt] key as modifier.
- create a Button with 'SecureActionButtonTemplate' as template, and the Frame created before as parent.
- create the texture for the button highlight.
- setup 'OnLeave' and 'OnEnter' scripts for the button to show and hide the button texture.
I know its late to post it, but there was a bug in version of my addon which I reffered to earlier, its fxed now:
If you wish to see it in action go download latest alpha of my addon http://wow.curseforge.com/addons/simplehud/files/ (its far from complete yet, but should be relative bug free)