my code looks like this: (Ive abbreviated for simplicity.)
...
local dirtyeditor = false -- At the moment for debugging this is a global but should be a local at the end.
...
local nameeditbox = AceGUI:Create("EditBox")
nameeditbox:SetLabel(L["Sequence Name"])
nameeditbox:SetWidth(250)
nameeditbox:SetCallback("OnTextChanged", function(self) currentSequence = self:GetText(); dirtyeditor = true end)
nameeditbox:DisableButton( true)
editframe:AddChild(nameeditbox)
...
stepdropdown:SetCallback("OnValueChanged", function (obj,event,key) stepvalue = key; dirtyeditor = true end)
editframe:AddChild(stepdropdown)
...
editframe:Show()
dirtyeditor = false
I added a bunch of print statements and what is occuring is that editframe:Show() is called, dirtyeditor is set to false but then every widget then fires its OnChange event twice (usually in a sequential order but not always the same order). This sets dirtyeditor to true before any user input can occur. Is there an API call I can hit to determine if a widget has changed or another way around this race condition?
Instead of unconditionally setting dirtyeditor to true, compare the current value with what was there before, and set dirtyeditor if they're actually different.
The code didn't show when you needed to know the value of dirtyeditor. So if you need to use it after a user has finished editing a field, you test the values in a different place than if you need to use it *while* the user is editing, etc.
Rollback Post to RevisionRollBack
To post a comment, please login or register a new account.
Hi All,
I'm trying to identify if a field on a frame has changed to determine what actions to take when closing a frame. The full code for this is located at https://github.com/TimothyLuke/GnomeSequenced-Enhanced/blob/master/GS-SequenceEditor/editor-core.lua
my code looks like this: (Ive abbreviated for simplicity.)
I added a bunch of print statements and what is occuring is that editframe:Show() is called, dirtyeditor is set to false but then every widget then fires its OnChange event twice (usually in a sequential order but not always the same order). This sets dirtyeditor to true before any user input can occur. Is there an API call I can hit to determine if a widget has changed or another way around this race condition?
Instead of unconditionally setting dirtyeditor to true, compare the current value with what was there before, and set dirtyeditor if they're actually different.
The code didn't show when you needed to know the value of dirtyeditor. So if you need to use it after a user has finished editing a field, you test the values in a different place than if you need to use it *while* the user is editing, etc.