Thanks for the tip @schamass and @dhj ,
I’ve used the radio button technique to select the inversion to be used in triads that are auto generated from a root note. When that worked as desired I tried to make a key selector in more or less the same way. It looks like this.
It is a horizontal slider, which floating point value gets scaled to an integer between 0 and 11. Then if the modifier is released the SetWidgetValue() function is used to center the slider in steps of 1/11, such that it aligns with the keyboard I drew underneath it. It sort of works, but I’m not entirely satisfied. Is there a nicer way to do this?
The function is as follows:
On WidgetValueChanged(newVal : double) from key var roundedVal : double key_centre = ScaleRange (newVal, 0, 11) roundedVal = IntToFloat(key_centre)/11 if selKey != key_centre then selKey = key_centre SetWidgetValue (key, roundedVal) end end