View Single Post
10-13-20, 06:05 PM   #1
LudiusMaximus
A Rage Talon Dragon Guard
 
LudiusMaximus's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2018
Posts: 320
Enforce SetValue() of AceConfig-3.0 slider?

I am using https://www.wowace.com/projects/ace3...options-tables for my addon's options. I have two sliders to define an interval: first slider "lower bound", second slider "upper bound".
Lower bound must never be greater than upper bound, and vice versa. So whenever the user drags one slider beyond the other slider's position, the other slider's value gets increased/decreased automatically. But visually, the other slider only gets updated after the user releases the dragged slider. Is there a way to refresh the other slider while the user is still dragging? I already tried `LibStub("AceConfigRegistry-3.0"):NotifyChange("MyAddon")` but this leads to the dragged slider being released at once.

Code:
lowerBound = {
  type = 'range',
  min = 0,
  max = 10,
  step = 1,
  get = function() return MyAddon.lowerBound end,
  set = function(_, newValue)
    MyAddon.lowerBound = newValue
    if MyAddon.upperBound < newValue then
      MyAddon.upperBound = newValue
      -- TODO: Update upperBound slider even while the user is still dragging lowerBound.
    end
  end,
},

upperBound = {
  type = 'range',
  min = 0,
  max = 10,
  step = 1,
  get = function() return MyAddon.upperBound end,
  set = function(_, newValue)
    MyAddon.upperBound = newValue
    if MyAddon.lowerBound > newValue then
      MyAddon.lowerBound = newValue
      -- TODO: Update lowerBound slider even while the user is still dragging upperBound.
    end
  end,
},
__________________
~ Be the change you want to see in the world... of warcraft interface! ~
  Reply With Quote