09/05/24, 02:52 PM | #1 |
|
Popup with controls
I would like the
Code:
AddCustomMenuItem( "Change Label Color", function() local color = nil color = unpack(self.labelSettings.labelColor) COLOR_PICKER:Show( function(...) self:SetLabelColor(...) end, color ) end ) What can I do to get the aforementioned controls in the window as well? I tried both ZO_Dialogs(see example below) and libDialog. Code:
ZO_Dialogs_RegisterCustomDialog("ExampleDialog", { setup = function(dialog) d("Setting up dialog controls") local parentControl = dialog.control local slider = CreateControlFromVirtual("$(parent)Slider", parentControl, "ZO_Slider") if slider then slider:SetAnchor(TOPLEFT, parentControl, TOPLEFT, 0, 20) slider:SetMinMax(0, 100) slider:SetValue(50) slider:SetValueStep(1) slider:SetHandler("OnValueChanged", function(_, value) d("Slider value: " .. value) end) dialog.slider = slider else d("Failed to create slider.") end end, title = { text = "Example Dialog", }, mainText = { text = "Adjust the slider:", }, buttons = { { text = "OK", callback = function(dialog) d("Confirmed with slider value: " .. dialog.slider:GetValue()) end, }, { text = "Cancel", callback = function(dialog) d("Dialog cancelled") end, }, }, }) SLASH_COMMANDS["/showdialog"] = function() ZO_Dialogs_ShowDialog("ExampleDialog") end Last edited by Amakesh : 09/05/24 at 02:56 PM. |
09/06/24, 02:49 AM | #2 |
Check my addon WishList, it got some ZO_Dialog popups with custom controls in it (defined in XML though).
It's code is old and could be improved I know but hopefully it explains it to you. You need to define the dialog first in a XML file as ZO_Dialog alone does not provide any custom dialogs with drodpowns afaik. -> It could work with controls created in the setup function too, not sure, never tested that actually. Try to add in your setup function: Code:
slider:SetHidden(false) slider:SetMouseEnabled(true) Else try it vial XML code: See file WishList/src/dialog/WishListAddItemDialog.xml Code:
<Controls> <TopLevelControl name="WishListAddItemDialog" inherits="ZO_CustomDialogBase" resizeToFitDescendents="true"> .... See function call in WishlistWindow.lua WL.WishListWindowAddItemInitialize(WishListAddItemDialog) Function is in dialogs.lua then Code:
function WL.WishListWindowAddItemInitialize(control) local content = GetControl(control, "Content") local acceptBtn = GetControl(control, "Accept") local cancelBtn = GetControl(control, "Cancel") local descLabel = GetControl(content, "Text") local labelLastAddedHistory = GetControl(content, "LastAddedHistoryLabel") local comboBoxBaseControlLastAddedHistory = content:GetNamedChild("LastAddedHistoryCombo") local comboLastAddedHistory = ZO_ComboBox_ObjectFromContainer(comboBoxBaseControlLastAddedHistory) local textureLastAddedHistory = content:GetNamedChild("LastAddedHistoryTexture") local labelItemType = GetControl(content, "ItemTypeText") local comboItemType = ZO_ComboBox_ObjectFromContainer(content:GetNamedChild("ItemTypeCombo")) --GetControl(content, "ItemTypeCombo") local labelArmorOrWeaponType = GetControl(content, "ArmorOrWeaponTypeText") local comboArmorOrWeaponType = ZO_ComboBox_ObjectFromContainer(content:GetNamedChild("ArmorOrWeaponTypeCombo")) --GetControl(content, "ArmorOrWeaponTypeCombo") local labelSlot = GetControl(content, "SlotText") local comboSlot = ZO_ComboBox_ObjectFromContainer(content:GetNamedChild("SlotCombo")) --GetControl(content, "SlotCombo") local labelTrait = GetControl(content, "TraitText") local comboTrait = ZO_ComboBox_ObjectFromContainer(content:GetNamedChild("TraitCombo")) --GetControl(content, "TraitCombo") local labelQuality = GetControl(content, "QualityText") local comboQuality = ZO_ComboBox_ObjectFromContainer(content:GetNamedChild("QualityCombo")) --GetControl(content, "QualityCombo") local labelChars = GetControl(content, "CharsText") local comboChars = ZO_ComboBox_ObjectFromContainer(content:GetNamedChild("CharsCombo")) --GetControl(content, "CharsCombo") ZO_Dialogs_RegisterCustomDialog("WISHLIST_EVENT_ADD_ITEM_DIALOG", { ... In the setup function of the dialog define what to do how: Code:
setup = function(dialog, data) --local wlWindow = (data ~= nil and data.wlWindow ~= nil and data.wlWindow == true) or false descLabel:SetText(WL.currentSetName) labelLastAddedHistory:SetText(GetString(WISHLIST_HEADER_LAST_ADDED)) labelItemType:SetText(GetString(WISHLIST_HEADER_TYPE)) --labelArmorOrWeaponType:SetText("Armor/Weapon Type") labelTrait:SetText(GetString(WISHLIST_HEADER_TRAIT)) labelQuality:SetText(GetString(WISHLIST_HEADER_QUALITY)) labelSlot:SetText(GetString(WISHLIST_HEADER_SLOT)) labelChars:SetText(GetString(WISHLIST_HEADER_CHARS)) WL.checkCharsData() ... It's done for my addon in a function WL.showAddItemalso in file dialogs.lua Lua Code:
Last edited by Baertram : 09/06/24 at 03:12 AM. |
|
ESOUI » Developer Discussions » Lua/XML Help » Popup with controls |
«
Previous Thread
|
Next Thread
»
|
Display Modes |
Linear Mode |
Switch to Hybrid Mode |
Switch to Threaded Mode |
|
|