【问题标题】:WoW - Adding event handler for modifier key - kgPanelsWoW - 为修饰键添加事件处理程序 - kgPanels
【发布时间】:2019-09-15 01:07:49
【问题描述】:

我正在使用 kgPanels 创建一个突袭标记实用程序。我有两个面板。一个面板用作按钮 - 我们将其称为 rmButton。当按下 rmButton 时,它会打开团队标记实用程序 - rmUtility。

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

现在一切正常,只要在目标上放置标记。我想添加更多功能,允许在按住任一换档按钮时放置世界标记。我在整合它时遇到了麻烦。

在我的 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")

在我的 OnEvent 脚本中:

if event == "PLAYER_REGEN_DISABLED" then
 self:Hide()
elseif event == "PLAYER_REGEN_ENABLED" then
 self:Hide()
end

加载此面板时,它会生成六个按钮 - 五个带有团队标记,一个用于清除标记。当按下按钮时面板会隐藏,当我进入战斗时面板会自动隐藏。

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

谢谢。

【问题讨论】:

    标签: lua world-of-warcraft


    【解决方案1】:

    你有没有尝试过类似的东西

    btn:SetAttribute("shift-macrotext1",("/wm %d"):format(n))
    

    https://wow.gamepedia.com/SecureActionButtonTemplate#Modified_attributes

    除非您的意思是要使用 Shift 来放置世界标记?而不是将其用作安全操作按钮的修饰符?我不知道任何修饰键(如 shift、ctrl、alt)能够激活操作按钮。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2023-04-03
      • 1970-01-01
      • 2012-01-18
      • 1970-01-01
      • 1970-01-01
      • 2018-07-14
      相关资源
      最近更新 更多