From 940a1adae052b83bf4b62d6aee281d06324663c3 Mon Sep 17 00:00:00 2001 From: Brues <5278969+brues-code@users.noreply.github.com> Date: Wed, 5 Aug 2026 21:21:55 -0500 Subject: [PATCH] Restore Clique support on unit frames Fixes #33. Clique's pfUI plugin replaces pfUI.uf.ClickAction and calls it from an OnClick script. The move to secure attribute clicks removed that function, so Clique stopped working. Add the legacy Lua click path back for Clique. When Clique is loaded, EnableScripts sets an OnClick script that runs ClickAction. When Clique is not loaded, the frames keep the secure attribute path. Skip the secure attributes in Clique mode. The type1 target attribute switches the target before Clique can cast. Right-click opens the unit menu through ClassicAPI_ToggleUnitMenu. --- api/unitframes.lua | 62 +++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 59 insertions(+), 3 deletions(-) diff --git a/api/unitframes.lua b/api/unitframes.lua index e1d775cc..747e2ef6 100644 --- a/api/unitframes.lua +++ b/api/unitframes.lua @@ -1209,16 +1209,72 @@ function pfUI.uf:EnableEvents() 'MiddleButtonUp', 'Button4Up', 'Button5Up') end +-- ============================================================ +-- Clique compatibility +-- Clique's pfUI plugin replaces pfUI.uf.ClickAction and expects an +-- OnClick script to call it (with `this` = frame, `arg1` = button). The +-- secure attribute path replaced that dispatch, so when Clique is loaded +-- EnableScripts routes clicks through this legacy Lua path instead. The +-- secure path is skipped there because type1="target" switches the target +-- before Clique can cast. +-- ============================================================ + +function pfUI.uf.OnClick() + if not this.label and this.unitname then + TargetByName(this.unitname, true) + else + pfUI.uf:ClickAction(arg1) + end +end + +function pfUI.uf:ClickAction(button) + local label = this.label or "" + local id = this.id or "" + local unitstr = label .. id + + if SpellIsTargeting() and button == "RightButton" then + SpellStopTargeting() + return + end + + if SpellIsTargeting() and button == "LeftButton" then + SpellTargetUnit(unitstr) + elseif CursorHasItem() then + DropItemOnUnit(unitstr) + end + + -- right-click opens the standard unit menu (ClassicAPI resolves the type) + if button == "RightButton" then + ClassicAPI_ToggleUnitMenu(unitstr) + return + end + + -- drop food on petframe + if label == "pet" and CursorHasItem() then + if UnitClassBase("player") == "HUNTER" then + DropItemOnUnit("pet") + return + end + end + + -- default click + TargetUnit(unitstr) +end + function pfUI.uf:EnableScripts() local f = self - f:SetAttribute("type1", "target") - f:SetAttribute("type2", "menu") + if IsAddOnLoaded("Clique") then + f:SetScript("OnClick", pfUI.uf.OnClick) + else + f:SetAttribute("type1", "target") + f:SetAttribute("type2", "menu") + f:EnableClickCast() + end f:SetScript("OnShow", pfUI.uf.OnShow) f:SetScript("OnEvent", pfUI.uf.OnEvent) f:SetScript("OnUpdate", pfUI.uf.OnUpdate) - f:EnableClickCast() -- add frame to visibility refresh handler visibilityscan.frames[f] = true