聊天栏快捷按钮
\Interface\AddOns\ShestakUI\Modules\Chat\ChatBars.lua
样式
local function CreateButton(f, c) f:Width(16) f:Height(16) f:SetTemplate() f:RegisterForClicks("AnyUp") f:SetScript("OnClick", c) --[[ f.t = f:CreateTexture(nil, "ARTWORK") -- 原样式 f.t:SetTexture(C.media.blank) f.t:Point("TOPLEFT", f, "TOPLEFT", 2, -2) f.t:Point("BOTTOMRIGHT", f, "BOTTOMRIGHT", -2, 2) ]] f.t = f:CreateFontString(nil, "OVERLAY") f.t:SetFont(unpack(font)) f.t:SetJustifyV("TOP") f.t:SetJustifyH("TOP") if f == sw then f.t:SetText("S") end if f == go then f.t:SetText("G") end if f == rp then f.t:SetText("P") end if f == yr then f.t:SetText("T") end if f == gt then f.t:SetText("2") end if f == lg then f.t:SetText("5") end f.t:SetPoint("LEFT",2,-1) end
/roll
-- ROLL local RFrame = CreateFrame("Frame", nil, UIParent) RFrame:SetWidth(16) RFrame:SetHeight(16) RFrame:SetBackdrop({ bgFile = [[Interface\Buttons\WHITE8x8]], insets = {left = 1,right = 1,top = 1,bottom = 1}, edgeFile = [[Interface\Buttons\WHITE8x8]], edgeSize = 1, }) RFrame:SetBackdropColor(0, 0, 0, 0.6) RFrame:SetBackdropBorderColor(255/255, 215/255, 0, 1) RFrame:SetPoint("BOTTOM",ChatBar,"TOP",0,3) local roll = CreateFrame("Button", "rollMacro", UIParent, "SecureActionButtonTemplate") roll:SetAttribute("*type*", "macro") roll:SetAttribute("macrotext", "/roll") --SetOverrideBindingClick(roll, true, "5", "rollMacro", nil) -- 把该宏绑在数字键5快捷键上 roll:SetWidth(15) roll:SetHeight(15) roll:SetPoint("RIGHT",RFrame,"RIGHT",1,-1) rollText =roll:CreateFontString("ROLLText", "OVERLAY") rollText:SetFont(unpack(font)) rollText:SetJustifyV("CENTER") rollText:SetJustifyH("CENTER") --rollText:SetWidth(16) --rollText:SetHeight(16) rollText:SetText("R") rollText:SetPoint("CENTER") rollText:SetTextColor(255/255, 215/255, 0)
点击事件
function cbar:SW(button) if button == "RightButton" then --右键 ChatFrame_OpenChat("/w ", SELECTED_DOCK_FRAME) elseif button == "MiddleButton" then -- 中键 ChatFrame_OpenChat("/y ", SELECTED_DOCK_FRAME) else -- 否则默认左键 ChatFrame_OpenChat("/s ", SELECTED_DOCK_FRAME) end end