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")
SimpleHUD["player"].clickable_Frame:SetAttribute("alt-type1", "target")
SimpleHUD["player"].clickable_Frame:SetAttribute("unit", "player")
SimpleHUD["player"].clickable_Frame:SetScript("OnEnter", function()
if IsAltKeyDown() then
SimpleHUD["player"].barBorder:SetAlpha(0.40)
end
end)
SimpleHUD["player"].clickable_Frame:SetScript("OnLeave", function()
if IsAltKeyDown() then
SHUD_BarFunctions:Update_PlayerAlpha()
end
end)
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 :)
The Solution:
- 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.
EDIT:
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)
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:
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.
Any help will be appreciated.
The Solution:
- 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.
EDIT:
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)