Référence › Référence des fonctions › UI

UI.checkbox.constructor

dépendance

Appel

UI.checkbox.constructor()

Enregistrez la dépendance UI.checkbox.constructor, puis appelez-la sous ce nom. Un appel par espace de noms ne transmet pas self : utilisez un appel avec deux-points ou passez l'objet vous-même.

Ce qu'elle fait

Constructs a new RM-CheckBox condition widget: a 180 by 24 frame holding a workbench check box, with SetLabel, SetValue, GetValue and SetDisabled, firing OnValueChanged when clicked. It returns the registered but not yet acquired widget; addon:CreateConditionCheckBox passes it to addon:AcquireConditionWidget, which reuses pooled instances.

Arguments

Aucun.

Retours

1RMConditionWidgetThe new check box widget, registered with the condition widget system.

Éditions

Les fonctions utilitaires intégrées sont enregistrées sur toutes les éditions. Ce qui diffère, c'est l'API du jeu qu'elles lisent ; quand l'une manque, la fonction utilitaire se rabat sur une alternative ou renvoie nil avec une raison.

  • Indisponible sur cette édition (la raison figure dans l'infobulle)
  • Uniquement tant que les solutions de repli de Blizzard pour les fonctions obsolètes sont actives
API du jeuClassic EraTBC AnniversaryClassic ProgressionForeverRetail
CreateFrameClassic EraTBC AnniversaryClassic ProgressionForeverRetail
UIParentClassic EraTBC AnniversaryClassic ProgressionForeverRetail

Exemple

-- needs the dependency UI.checkbox.constructor
local box = addon:AcquireConditionWidget("RM-CheckBox", UI.checkbox.constructor)
box:SetLabel(L["Only in combat"])
box:SetValue(value.combat == true)
box:SetCallback("OnValueChanged", function(_, _, checked) value.combat = checked end)
parent:AddChild(box)

Source

UI/checkbox.lua, ligne 24. En lecture seule dans le jeu ; Dupliquer crée une copie modifiable.

UI.checkbox.constructor()
    local w={type='RM-CheckBox',alive=false,disabled=false}
    local frame=CreateFrame('Frame',nil,UIParent);w.frame=frame;frame:SetSize(180,24)
    local button=addon:CreateWorkbenchCheckBox(frame,'',180);w.button=button;button:SetAllPoints(frame)
    function w:OnAcquire() self.alive=true;button.tooltip=nil;self:SetLabel('');self:SetValue(false);self:SetDisabled(false);self:SetWidth(180);self:SetHeight(24) end
    function w:OnRelease() self.alive=false;self:SetValue(false) end
    function w:SetLabel(text) button:SetText(text or '') end
    function w:SetValue(value) button:SetChecked(value==true) end
    function w:GetValue() return button:GetChecked() end
    function w:SetDisabled(value) self.disabled=value==true;if self.disabled then button:Disable();button:SetAlpha(.45) else button:Enable();button:SetAlpha(1) end end
    function w:OnWidthSet(width) button:GetFontString():SetWidth(math.max(1,width-22)) end
    addon:SetUIScript(button,'OnClick',function()
        if not w.alive or w.disabled then return end
        w:SetValue(not w:GetValue());w:Fire('OnValueChanged',w:GetValue())
    end)
    ---@cast w RMConditionWidget
    return addon:RegisterConditionWidget(w)

Retour à Référence des fonctions