View Single Post
Old 02-11-2019, 07:00 PM   #5
nofish
Human being with feelings
 
nofish's Avatar
 
Join Date: Oct 2007
Location: home is where the heart is
Posts: 8,458
Default

Just assign your toolbar button to the defer script with above code in it and it should work.

edit:
More complete minimal example:

Code:
-- defer demo
_, _, sectionID, cmdID, _, _, _ = reaper.get_action_context()
-- set toggle state to on
reaper.SetToggleCommandState(sectionID, cmdID, 1);
reaper.RefreshToolbar2(sectionID, cmdID);

function Main() -- your defer code
  reaper.ShowConsoleMsg("defer script running...\n")
  reaper.defer(Main)
end

Main()

function DoAtExit()
  -- set toggle state to off
  reaper.SetToggleCommandState(sectionID, cmdID, 0);
  reaper.RefreshToolbar2(sectionID, cmdID);
end

reaper.atexit(DoAtExit)


First time you stop the script via toolbar, Reaper asks about terminating instances. Click yes and remember answer.

Last edited by nofish; 02-11-2019 at 07:27 PM.
nofish is offline   Reply With Quote