Lua WoW-为修改器键添加事件处理程序-KG面板

Lua WoW-为修改器键添加事件处理程序-KG面板,lua,world-of-warcraft,Lua,World Of Warcraft,我正在与KGMpanels合作创建raid标记实用程序。我有两个面板。一个面板作为一个按钮,我们称之为rmButton。当按下rmButton时,它会打开raid标记实用程序-rmUtility 在kgPanels中,您可以创建一个面板,在该面板上可以添加在许多不同处理程序中的脚本。对于rmUtility,我使用OnLoad和OnEvent 目前,一切都在进行中,甚至在目标上设置了标记。我想添加更多的功能,允许在按住shift键时放置世界标记。我很难把它整合起来 在我的OnLoad脚本中: lo

我正在与KGMpanels合作创建raid标记实用程序。我有两个面板。一个面板作为一个按钮,我们称之为rmButton。当按下rmButton时,它会打开raid标记实用程序-rmUtility

在kgPanels中,您可以创建一个面板,在该面板上可以添加在许多不同处理程序中的脚本。对于rmUtility,我使用OnLoad和OnEvent

目前,一切都在进行中,甚至在目标上设置了标记。我想添加更多的功能,允许在按住shift键时放置世界标记。我很难把它整合起来

在我的OnLoad脚本中:

local btnWidth = 30 -- the width of each button
local btnHeight = 30 -- the height of each button
local leftBorderOffset = 7 -- from the left border of the kgPanel to the first button
local btnOffset = 7 -- pixels between the buttons
local topBorderOffset = -7
self:RegisterEvent ("PLAYER_REGEN_DISABLED")
self:RegisterEvent ("PLAYER_REGEN_ENABLED")
self:Show()


self.buttons = {}
local hideFunc = function(s) s.parent:Hide() end
for n=1,6 do
    local btn = CreateFrame("Button",nil,self,"SecureActionButtonTemplate")
    btn:SetSize(btnWidth, btnHeight) -- replace this
    btn:SetPoint("TOP",0,topBorderOffset - ((n-1) * (btnHeight + btnOffset)))
    btn:SetAttribute("type","macro")
    btn:RegisterForClicks("AnyUp")
    btn.parent = self
    btn:SetScript("PostClick",hideFunc)
    btn:RegisterEvent ("MODIFIER_STATE_CHANGED")
    if (event == "MODIFIER_STATE_CHANGED") then
        if n == 6 then
            btn:SetAttribute("macrotext","/cwm all")
        else
            btn:SetAttribute("macrotext",("/wm %d"):format(n))
        end
    else
        if n == 6 then
            btn:SetAttribute("macrotext","/tm 0")
        else
            btn:SetAttribute("macrotext",("/tm %d"):format(n))
        end
    end
    self.buttons[n] = btn
end
self.buttons[1]:SetNormalTexture("Interface\\AddOns\\SharedMedia\\background\\Square.tga")
self.buttons[2]:SetNormalTexture("Interface\\AddOns\\SharedMedia\\background\\Triangle.tga")
self.buttons[3]:SetNormalTexture("Interface\\AddOns\\SharedMedia\\background\\Diamond.tga")
self.buttons[4]:SetNormalTexture("Interface\\AddOns\\SharedMedia\\background\\Cross.tga")
self.buttons[5]:SetNormalTexture("Interface\\AddOns\\SharedMedia\\background\\Star.tga")
self.buttons[6]:SetNormalTexture("Interface\\AddOns\\SharedMedia\\background\\Clear.tga")
在我的OneEvent脚本中:

if event == "PLAYER_REGEN_DISABLED" then
 self:Hide()
elseif event == "PLAYER_REGEN_ENABLED" then
 self:Hide()
end
当该面板加载时,它会生成六个按钮-五个带有raid标记,一个清除标记。当按下按钮时,面板将隐藏,当我进入战斗时面板将自动隐藏

如前所述,我需要面板接受“shift”修改键来放置世界标记


谢谢。

你试过类似的东西吗

btn:SetAttribute(“shift-macrotext1”(“/wm%d”):格式(n))

除非您的意思是要使用Shift来放置世界标记?而不是将其用作安全操作按钮的修改器?我不知道像shift、ctrl、alt这样的修改键能够激活动作按钮