🔥 Lifetime deal! Get Control Surface Studio for Just £67 👉 Click Here To Get It
Time left... mailtimers.com
⚠️ Lifetime licenses are ending soon, get yours before they're gone ⚠️
Your shopping cart is empty.

Selected Track Listener in Reactions

Submitted by Hugo Kant on Sun, 10/30/2022 - 12:34
Hugo Kant
Control Surface Studio User

Most of the problems i have so far with trying to do my template for touchosc with CSS comes from the fact that when i try to use "selected_track" to create a listener in a reaction it seems that it only works for the currently selected track when the script is initialized.
For exemple creating a reaction with "Track's name value has changed" (self.song().view.selected_track.add_name_listener) works fine but only for the track selected on init().

Is this a bug or the intented behaviour ?
would like to know.
Thanks!

Topic Category: 

5 Responses

Comments

JohnC
Forum Admin
#1

If I understand you correctly, you're saying that only the track which is selected when the script is initialised is classed as the selected track (changing the selected track has no effect)?

If you add a new track to the session, does it update?

Hugo Kant
Control Surface Studio User
#2

Hi John!

Selected track works for all the controls i use in my template (volumes, mutes, sends...) but not when used as a listener for example when the selected track name has changed.
It works only for 1 track, the one selected on init() and if i add a new track to the session like you said it updates but then it only works for the newly created track.

Hugo Kant
Control Surface Studio User
#3

Something like that would work i think :

def set_selected_track_listeners(self):
if(self.song().view.selected_track.name_has_listener(self.custom_listener)):
self.song().view.selected_track.remove_name_listener(self.custom_listener)
self.song().view.selected_track.add_name_listener(self.custom_listener)

Also when trying to get the id of the selected track (get_selected_track_num) it does not work for return tracks, your script returns false because it cannot find it.
You may want to add a function to check if the selected track is a return track before :

def is_return_track(self, track):
rt = self.song().return_tracks
for i in range(0, len(rt)):
if (rt[i] == track):
return(True)
return(False)

maybe there's a better way but that's what i've done so far.

JohnC
Forum Admin
#4
verdeal
Pro User
#5

Same problem here :)