I think this will work, havent play-tested it, but I have a good feeling
XML file:
Code:
<Ui xmlns="http://www.blizzard.com/wow/ui/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.blizzard.com/wow/ui/
..\FrameXML\UI.xsd">
<Script file="FocusEye.lua"/>
<Button name="FocusButton" parent="UIParent" toplevel="true" hidden="false" enableMouse="true" movable="true" inherits="SecureActionButtonTemplate">
<Layers>
<Layer level="ARTWORK">
<Texture name="MyTexture" file="Interface\AddOns\FocusEye\Clear"/>
</Layer>
</Layers>
<Size>
<AbsDimension x="20" y="20"/>
</Size>
<Anchors>
<Anchor point="TOPRIGHT"/>
<Offset>
<AbsDimension x="-200" y="-200"/>
</Offset>
</Anchor>
</Anchors>
<Scripts>
<OnLoad>this:RegisterForDrag("LeftButton"); thisRegisterForClicks("LeftButtonUp");
<OnClick>FocusToggle();</OnClick>
<OnDragStart>this:StartMoving();</OnDragStart>
<OnDragStop>this:StopMovingOrSizing();</OnDragStop>
<OnEnter>FocusEnter();</OnEnter>
<OnLeave>FocusLeave();</OnLeave>
</Scripts>
</Button>
</Ui>
LUA file:
Code:
function FocusToggle()
if UnitExists("focus") then
FocusUnit("none");
FocusButton:SetTexute(Interface\AddOns\FocusEye\Clear);
elseif UnitExists("target") then
FocusUnit("target");
FocusButton:SetTexture(Interface\AddOns\FocusEye\Focussed);
end
end
function FocusEnter()
GameTooltip:SetOwner(this, "ANCHOR_RIGHT");
GameTooltip:SetText("Focus\nLeft-Click to set focus");
GameTooltip:Show();
end
function FocusLeave()
GameTooltip:Hide();
end
I added some tooltip code and some script events for dragging.
Good luck!