WoWInterface SVN Eui

[/] [Eui/] [script/] [Focuser.lua] - Rev 2

Compare with Previous | Blame | View Log

local E, C = unpack(select(2, ...))
if C["other"].focuser ~= true then return end

local modifier = "shift" -- shift, alt or ctrl
local mouseButton = "1" -- 1 = left, 2 = right, 3 = middle, 4 and 5 = thumb buttons if there are any

local function SetFocusHotkey(frame)
        frame:SetAttribute(modifier.."-type"..mouseButton,"focus")
end

local function CreateFrame_Hook(type, name, parent, template)
        if name and template == "SecureUnitButtonTemplate" then
                SetFocusHotkey(_G[name])
        end
end

hooksecurefunc("CreateFrame", CreateFrame_Hook)

-- Keybinding override so that models can be shift/alt/ctrl+clicked
local f = CreateFrame("CheckButton", "FocuserButton", UIParent, "SecureActionButtonTemplate")
f:SetAttribute("type1","macro")
f:SetAttribute("macrotext","/focus mouseover")
SetOverrideBindingClick(FocuserButton,true,modifier.."-BUTTON"..mouseButton,"FocuserButton")

-- Set the keybindings on the default unit frames since we won't get any CreateFrame notification about them
local duf = {
        PlayerFrame,
        PetFrame,
        PartyMemberFrame1,
        PartyMemberFrame2,
        PartyMemberFrame3,
        PartyMemberFrame4,
        PartyMemberFrame1PetFrame,
        PartyMemberFrame2PetFrame,
        PartyMemberFrame3PetFrame,
        PartyMemberFrame4PetFrame,
        TargetFrame,
        TargetofTargetFrame,
        oUF_monoPlayerFrame,
        oUF_monoTargetFrame,
        oUF_mono_ToTFrame,
        oUF_mono_FoTFrame,
        oUF_AftermathhPlayer,
        oUF_AftermathhTarget,
        oUF_AftermathhTargettarget,
        oUF_AftermathhFocustarget,
}

for i,frame in pairs(duf) do
        SetFocusHotkey(frame)
end

Compare with Previous | Blame