Quote:
Originally Posted by reapero
Because the menubox preset selector is inside the main loop
|
I'm confused; why is the preset selector in your main loop? You should just have to attach your handler to the menubox so it's run every time the user chooses a preset. Something like:
Code:
local function updateOtherElements()
...
end
function GUI.elms.myMenuBox:onmouseup()
GUI.Menubox.onmouseup(self)
updateOtherElements()
end
function GUI.elms.myMenuBox.onmouseup()
GUI.Menubox.onwheel(self)
updateOtherElements()
end
Quote:
So, if i want to keep it simple with just the menubox, is there a way to call a function from the loop but only once? Ideally updating the GUI with the preset data should happen only when the menubox selector changes, not on every loop.
|
If you do need to have it in the main loop, for whatever reason, then something like this will do the trick:
Code:
local presetWasChanged = false
function GUI.elms.myMenuBox:onmouseup()
GUI.Menubox.onmouseup(self)
presetWasChanged = true
end
function GUI.elms.myMenuBox.onmouseup()
GUI.Menubox.onwheel(self)
presetWasChanged = true
end
local function mainLoop()
if presetWasChanged then
-- Update the other elements
presetWasChanged = false
else
-- Do something else
end
reaper.defer(mainLoop)
end
mainLoop()