|
|
|
03-23-2020, 10:48 AM
|
#1
|
Human being with feelings
Join Date: Apr 2015
Posts: 102
|
How do I make a toolbar button that changes color along with a lua script state?
Hi!
I have a lua script that mimics Pro Tools "Insertion Follows playback".
Pressing N toggles between the two states.
I'd like to create a toolbar button that becomes blue when "insertion follows playback is" Active. This way I can see the state of the script visually.
The problem is that this only works with regular toggle actions from the action menu, not scripts.
I've read something about the actions "Dummy toggle" and "Exclusive toggle" perhaps being able to do what I need, but I'm not sure how...
If someone could teach me how to do this I'd be grateful.
/Jonas
|
|
|
03-23-2020, 10:57 AM
|
#2
|
Human being with feelings
Join Date: May 2015
Location: Québec, Canada
Posts: 4,970
|
It's up to the script to set and update its toggle state.
|
|
|
03-23-2020, 11:30 AM
|
#3
|
Human being with feelings
Join Date: Apr 2015
Posts: 102
|
Ok, can I assume that this script does not report its toggle state?
(Since I can get regular toggle actions to toggle toolbar button color but not this script)
|
|
|
03-24-2020, 03:04 AM
|
#4
|
Human being with feelings
Join Date: Apr 2015
Posts: 102
|
So how do I modify this script so it reports it's toggle state;
Quote:
state = reaper.HasExtState("playtoggle", "togglevalue")
if state then
value = reaper.GetExtState("playtoggle", "togglevalue")
if value == "1" then
reaper.SetExtState("playtoggle", "togglevalue", "0", true)
else
reaper.SetExtState("playtoggle", "togglevalue", "1", true)
end
end
|
|
|
|
03-24-2020, 08:31 AM
|
#5
|
Human being with feelings
Join Date: May 2015
Location: Québec, Canada
Posts: 4,970
|
Code:
if not reaper.HasExtState("playtoggle", "togglevalue") then
return
end
local scriptSection = ({reaper.get_action_context()})[3]
local scriptId = ({reaper.get_action_context()})[4]
local value = reaper.GetExtState("playtoggle", "togglevalue")
value = value == '1' and 0 or 1
reaper.SetExtState("playtoggle", "togglevalue", value, true)
reaper.SetToggleCommandState(scriptSection, scriptId, value)
reaper.RefreshToolbar2(scriptSection, scriptId)
|
|
|
03-25-2020, 04:31 AM
|
#6
|
Human being with feelings
Join Date: Apr 2015
Posts: 102
|
Donated.
Thanks alot, Christian, works perfectly!
|
|
|
Thread Tools |
|
Display Modes |
Linear Mode
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
All times are GMT -7. The time now is 05:53 PM.
|