local _,ns = ...
ns.ADDUIEVENT("PLAYER_LOGIN", function()
if AddUIDB.sf ==  false  then return end

----------- shift+左键点击头像或者目标快速设置系统焦点，shift+左键点击空白区域则取消-------

local modifier = "shift" --按住shift，也可设置为alt或者crtl 
local mouseButton = "1" --鼠标按键 1是左键、2是右键、3是中键 

local f = CreateFrame("CheckButton", "ShiftFocuserButton", UIParent, "SecureActionButtonTemplate")
f:SetAttribute("type", "macro")
f:SetAttribute("macrotext", "/focus [@mouseover]")--\n/script SetRaidTarget('mouseover',5)
f:RegisterForClicks("AnyDown", "AnyUp")
SetOverrideBindingClick(ShiftFocuserButton, true, modifier.."-BUTTON"..mouseButton, "ShiftFocuserButton")

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)

--团队框架设焦点http://bbs.ngacn.cc/read.php?&tid=13684940&pid=281141400&to=1
hooksecurefunc("CompactUnitFrame_UpdateName", function(frame, ...)
	if InCombatLockdown() then return end
	if frame then
		SetFocusHotkey(frame)
	end
end)

local duf = {
	PetFrame,
	PlayerFrame,
	PartyMemberFrame1,
	PartyMemberFrame2,
	PartyMemberFrame3,
	PartyMemberFrame4,
	PartyMemberFrame1PetFrame,
	PartyMemberFrame2PetFrame,
	PartyMemberFrame3PetFrame,
	PartyMemberFrame4PetFrame,
	PartyMemberFrame1TargetFrame,
	PartyMemberFrame2TargetFrame,
	PartyMemberFrame3TargetFrame,
	PartyMemberFrame4TargetFrame,
	TargetFrame,
	TargetFrameToT,
	TargetFrameToTTargetFrame,
	Boss1TargetFrame,
	Boss2TargetFrame,
	Boss3TargetFrame,
	Boss4TargetFrame,
	Boss5TargetFrame,
	ArenaEnemyFrame1,
	ArenaEnemyFrame2,
	ArenaEnemyFrame3,
	ArenaPrepFrame1,
	ArenaPrepFrame2,
	ArenaPrepFrame3,
	ArenaFrame1,
	ArenaFrame2,
	ArenaFrame3,
}

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

end)