Selected Track Listener in Reactions
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!
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.
Sign up
User registration is currently not allowed.