參考資料 › 函式參考 › Conditions

Conditions.bossmod.idEditor

相依項目

呼叫方式

Conditions.bossmod.idEditor(parent, label, current, changed)

記錄相依項目 Conditions.bossmod.idEditor,然後以該名稱呼叫。含命名空間的呼叫不會傳入 self:請使用冒號呼叫,或自行傳入該物件。

作用

Builds a full-width edit box for an optional boss-mod ID (such as the encounter ID) and adds it to parent. On Enter it passes the typed number to changed only when validID accepts it, otherwise nil, and rewrites the box to the accepted ID or blank.

參數

名稱類型作用
parenttableCondition widget group the control is added to.
labelstringLabel shown above the edit box.
currentnumber | nilSaved ID to display; nil shows an empty box.
changedfunctionCalled with the accepted positive whole-number ID, or nil when the text is blank or invalid.

傳回值

1RMConditionInputThe edit box, already added to parent.

版本

內建輔助函式在每個版本上都會註冊。不同的是它們讀取的遊戲 API;某個 API 不存在時,輔助函式會改用備用方式,或傳回 nil 並附上原因。

它不會直接讀取任何遊戲 API。

插件如何呼叫它

  • 首領模組首領戰 (widget)
    idEditor(parent, L["Encounter ID (blank for any)"], value.encounter, function(id) value.encounter = id; update() end)
  • 首領模組計時條 (widget)
    idEditor(parent, L["Boss ability spell ID"], value.spell, function(id)

相依項目

原始碼

Conditions/bossmod.lua,第 70 行。在遊戲中為唯讀;「複製」會產生一份可編輯的複本。

Conditions.bossmod.idEditor(parent, label, current, changed)
    local edit = addon:CreateConditionEditBox()
    edit:SetFullWidth(true)
    edit:SetLabel(label)
    edit:SetText(current and tostring(current) or "")
    edit:SetCallback("OnEnterPressed", function(_, _, text)
        local id = tonumber(text)
        changed(validID(id) and id or nil)
        edit:SetText(validID(id) and tostring(id) or "")
    end)
    parent:AddChild(edit)
    return edit

返回函式參考