I'm creating some options using Ace-Config for an addon and I'm having an issue where the toggle/checkbox is requiring multiple clicks to change. Anyone have an idea why? I was able to create a normal checkbox and it works fine. I'm hooking functions to it via the regular options and it's using the global wow functions SetBagSlotFlag/GetBagSlotFlag in order to store the options. So I'm not sure if that might have something to do with it?
options = {
type = "group",
args = {
bag4 = {
name = "Bag 4",
desc = "Allow this bag to be sorted",
type = "toggle",
set = function(info,val)
SetBagSlotFlag(4, LE_BAG_FILTER_FLAG_IGNORE_CLEANUP, not val)
end,
get = function(info)
return not GetBagSlotFlag(4, LE_BAG_FILTER_FLAG_IGNORE_CLEANUP)
end,
order = 2,
width = "half"
}
}
}
LibStub("AceConfig-3.0"):RegisterOptionsTable("MyAddon", options, {"MyAddon"})
LibStub("AceConfigDialog-3.0"):AddToBlizOptions("MyAddon", "MyAddon")
Your logic seems fine, but GetBagSlotFlag() doesn't instantly return the updated values
E.g. if you refresh the options window (by clicking some other option or with a script) when BAG_SLOT_FLAGS_UPDATED fires, you'll see the toggle update correctly after a moment. You can check this with /etrace
local f = CreateFrame("Frame")
f:RegisterEvent("BAG_SLOT_FLAGS_UPDATED")
f:SetScript("OnEvent", function()
LibStub("AceConfigRegistry-3.0"):NotifyChange("MyAddon")
end)
I can't really think of a non crappy workaround that instantly updates the toggle with the correct value while still reading from GetBagSlotFlag(). Maybe with some extra variable that tracks the state of the toggle and the actual bag setting
Yeah, this is definitely what is going on. As I noticed when I check a box and then another box a couple seconds later they both update. I will probably shift this away from functions to saved variables instead.
Thanks!
Rollback Post to RevisionRollBack
To post a comment, please login or register a new account.
I'm creating some options using Ace-Config for an addon and I'm having an issue where the toggle/checkbox is requiring multiple clicks to change. Anyone have an idea why? I was able to create a normal checkbox and it works fine. I'm hooking functions to it via the regular options and it's using the global wow functions SetBagSlotFlag/GetBagSlotFlag in order to store the options. So I'm not sure if that might have something to do with it?
Your logic seems fine, but GetBagSlotFlag() doesn't instantly return the updated values
E.g. if you refresh the options window (by clicking some other option or with a script) when BAG_SLOT_FLAGS_UPDATED fires, you'll see the toggle update correctly after a moment. You can check this with /etrace
I can't really think of a non crappy workaround that instantly updates the toggle with the correct value while still reading from GetBagSlotFlag(). Maybe with some extra variable that tracks the state of the toggle and the actual bag setting
In reply to Ketho17:
Yeah, this is definitely what is going on. As I noticed when I check a box and then another box a couple seconds later they both update. I will probably shift this away from functions to saved variables instead.
Thanks!