呼叫方式
UI.condition_position.constructor()
記錄相依項目 UI.condition_position.constructor,然後以該名稱呼叫。含命名空間的呼叫不會傳入 self:請使用冒號呼叫,或自行傳入該物件。
作用
Constructs a new RM-ConditionPositionPad widget around the shared workbench directional pad, with SetDisabled, firing OnOffsetChanged (horizontal and vertical direction, whether Center was pressed, and the step) only while its lease is live and it is enabled. It returns the registered but not yet acquired widget; addon:CreateConditionPositionPad acquires it.
參數
無。
傳回值
| 1 | RMConditionWidget | The new position pad widget, registered with the condition widget system. |
|---|
版本
內建輔助函式在每個版本上都會註冊。不同的是它們讀取的遊戲 API;某個 API 不存在時,輔助函式會改用備用方式,或傳回 nil 並附上原因。
- 該版本無法使用(原因請見提示)
- 僅在暴雪的棄用相容層開啟時
| 遊戲 API | |||||
|---|---|---|---|---|---|
CreateFrame | |||||
UIParent |
範例
-- needs the dependency UI.condition_position.constructor
local pad = addon:AcquireConditionWidget("RM-ConditionPositionPad", UI.condition_position.constructor)
pad:SetCallback("OnOffsetChanged", function(_, _, dx, dy, center, amount)
if center then value.x = 0 else value.x = (value.x or 0) + dx * amount end
end)
parent:AddChild(pad)原始碼
UI/condition_position.lua,第 23 行。在遊戲中為唯讀;「複製」會產生一份可編輯的複本。
UI.condition_position.constructor()
local w={type='RM-ConditionPositionPad',disabled=false}
local frame=CreateFrame('Frame',nil,UIParent);w.frame=frame
local pad=addon:CreateWorkbenchPositionPad(frame);w.pad=pad;pad:SetPoint('TOPLEFT')
local clicks={}
for name,button in pairs(pad.buttons) do clicks[name]=button:GetScript('OnClick') end
function w:SetDisabled(value)
self.disabled=value==true
for _,button in pairs(pad.buttons) do if self.disabled then button:Disable() else button:Enable() end end
end
function w:OnAcquire()
self:SetWidth(48);self:SetHeight(48);self:SetDisabled(false)
local lease=self.rmLease
local function live() return w.rmActive and w.rmLease==lease and not w.disabled and not w:IsReleasing() end
pad:Bind(function(dx,dy,center,amount) w:Fire('OnOffsetChanged',dx,dy,center,amount) end,live,false)
for name,button in pairs(pad.buttons) do
local click=clicks[name]
addon:SetUIScript(button,'OnClick',function(...) if live() then return click(...) end end)
end
end
function w:OnRelease()
pad:Bind(nil,nil,true);self.disabled=true
end
return addon:RegisterConditionWidget(w)




