Thread Tools Display Modes
10/19/23, 08:52 AM   #1
ExoY
 
ExoY's Avatar
AddOn Author - Click to view addons
Join Date: Feb 2020
Posts: 88
Popup Dialog - Disable Button and Real Time Check

hello,

I am currently trying to find a way, to dynamically change some aspects of the zos dialog popups.

Specifically, I have a Dialog with a Textbox, and a List of already existing strings. What I would like to achieve is to check the current input of the textbox against the string table, and if it already exists disable the confirm button.

Here is how i currently define the Dialog, and then I just call it with `ZO_Dialogs_ShowDialog(*uniqueId*)`

Lua Code:
  1. ESO_Dialogs[uniqueId] = {
  2.         canQueue = true,
  3.         uniqueIdentifier = uniqueId,
  4.         title = {text = "Title"},
  5.         mainText = {text = "Content"},
  6.         editBox = {},
  7.         buttons = {
  8.             [1] = {
  9.                 text = SI_DIALOG_CONFIRM,
  10.                 callback = function(dialog)
  11.                     local input = ZO_Dialogs_GetEditBoxText(dialog)
  12.                     d(input)
  13.                 end,
  14.             },
  15.             [2] = {
  16.                 text = SI_DIALOG_CANCEL,
  17.                 callback = function()
  18.                        d("cancel")
  19.                 end,
  20.             },
  21.         },
  22. }

Does anybody already has experience with that sort of thing or knows of an existing addon that already does it?
  Reply With Quote
10/19/23, 11:35 AM   #2
Baertram
Super Moderator
 
Baertram's Avatar
WoWInterface Super Mod
AddOn Author - Click to view addons
Join Date: Mar 2014
Posts: 4,989
I think you can add a disabled or visible=function()...end to the buttons,but I'm not sure any more. Maybe it was at the keybind only.

If this does not exist or work you need to manually update the buttons visibility. And make the callback func do nothing if one uses the keybind. I think I had done this in an addon, not sure where anymore though.
Maybe it was the FCO ItemSaver anti-destroy protection at the destroy dialog. It hides the accept/ok button if an item is protected.

But as each dialog reuses the same controls make sure to reebable and show the buttons again on dialog close so the next dialog properly shows them again!


Another idea is to check ZOs code at the destroy dialog where you need to enter a special text to allow the destroying. Maybe you can turn it around somehow to disallow or only allow if the entered text is not in a list already

https://github.com/esoui/esoui/blob/...alogs.lua#L204

It's using "matchingString = " to compare the text.
Which will be passed to:
https://github.com/esoui/esoui/blob/...ialog.lua#L698

Which is an editbox of type ZO_RequiredTextFields:
https://github.com/esoui/esoui/blob/...lates.lua#L200

Maybe you can define your own editBox of a similar type which checks your table then, and create a custom dialog using your own editbox type?

Last edited by Baertram : 10/20/23 at 05:11 AM.
  Reply With Quote
10/20/23, 05:07 AM   #3
Baertram
Super Moderator
 
Baertram's Avatar
WoWInterface Super Mod
AddOn Author - Click to view addons
Join Date: Mar 2014
Posts: 4,989
Found some functions to use, to disable/enable the buttons:

Code:
-- Activate or deactivate a button...use BSTATE_NORMAL to activate and BSTATE_DISABLED to deactivate
function ZO_Dialogs_UpdateButtonState(dialog, buttonNumber, buttonState)

-- Update the text on a button itself
function ZO_Dialogs_UpdateButtonText(dialog, buttonNumber, text)

function ZO_Dialogs_UpdateButtonVisibilityAndEnabledState(dialog)
-> This function is checking "if buttonInfo.visible ~= nil then"
so there seems to be that .visible = function() return not inMyTable[text] end or similar
--> See code here: https://github.com/esoui/esoui/blob/2da96c11b9db89d1b48bc7ab014af25fbe1c1931/esoui/libraries/zo_dialog/zo_dialog.lua#L1081C13-L1081C46

And you also got buttonInfo.enabled
  Reply With Quote
10/20/23, 09:49 AM   #4
ExoY
 
ExoY's Avatar
AddOn Author - Click to view addons
Join Date: Feb 2020
Posts: 88
Thanks for your responds.

I will get back to you if I have any remaining issues, once I have time to check out everything
  Reply With Quote

ESOUI » Developer Discussions » General Authoring Discussion » Popup Dialog - Disable Button and Real Time Check


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off