Справочник › Справочник функций › UI

UI.condition_position.constructor

зависимость

Как вызывать

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.

Аргументы

Нет.

Возвращает

1RMConditionWidgetThe new position pad widget, registered with the condition widget system.

Издания

Встроенные помощники регистрируются во всех изданиях. Различается игровой API, который они читают; если нужного API нет, помощник использует запасной вариант или возвращает nil с причиной.

  • Недоступно в этом издании (причина — во всплывающей подсказке)
  • Только пока включены запасные реализации Blizzard для устаревших функций
Игровой APIClassic EraTBC AnniversaryClassic ProgressionForeverRetail
CreateFrameClassic EraTBC AnniversaryClassic ProgressionForeverRetail
UIParentClassic EraTBC AnniversaryClassic ProgressionForeverRetail

Пример

-- 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)

Назад: Справочник функций