Hi,
I have been struggling to get the Next and Previous buttons to work in conjuction with the key colour change.
I would like the colour change to update when I select a new set of groups using the next and previous buttons. The colour change only happens when I use the drop down menu to select the groups. There are 3 mic positions, hence the use of cases in the "on note" code block to select multiple groups. Each set of samples has a different key range.
Please can someone help? Thanks in advance.
on init
	make_perfview
	set_script_title("MIXER")
	declare const $UI_HEIGHT := 523
	set_ui_height_px(523)
	set_skin_offset(0)
	message ("")
declare ui_menu $PRESET_MENU
	move_control_px($PRESET_MENU, 102, 72)
	set_control_par(get_ui_id($PRESET_MENU), $CONTROL_PAR_WIDTH, 120)
		add_menu_item ($PRESET_MENU, "ALL SAMPLES", 0)
		add_menu_item ($PRESET_MENU, "SAMPLE A1", 3)
 
    declare $counter
    declare %key_color[128]
    $counter := 0
    while ($counter <= 127)
        %key_color[$counter] := $KEY_COLOR_BLACK
        inc($counter)
    end while
make_persistent($PRESET_MENU)
read_persistent_var ($PRESET_MENU)
{PRESET MENU - PREV + NEXT BUTTONS}
	declare ui_switch $PRESET_MENU_PREV_BUTTON
	move_control_px($PRESET_MENU_PREV_BUTTON, 228, 66)
	set_control_par_str(get_ui_id($PRESET_MENU_PREV_BUTTON), $CONTROL_PAR_PICTURE, "Prev_Button")
	set_control_par(get_ui_id($PRESET_MENU_PREV_BUTTON), $CONTROL_PAR_HEIGHT, 80)
	set_control_par(get_ui_id($PRESET_MENU_PREV_BUTTON), $CONTROL_PAR_WIDTH, 80)
	set_control_par(get_ui_id($PRESET_MENU_PREV_BUTTON), $CONTROL_PAR_TEXTPOS_Y, 1000)
	make_persistent($PRESET_MENU_PREV_BUTTON)
	declare ui_switch $PRESET_MENU_NEXT_BUTTON
	move_control_px($PRESET_MENU_NEXT_BUTTON, 252, 66)
	set_control_par_str(get_ui_id($PRESET_MENU_NEXT_BUTTON), $CONTROL_PAR_PICTURE, "Next_Button")
	set_control_par(get_ui_id($PRESET_MENU_NEXT_BUTTON), $CONTROL_PAR_HEIGHT, 80)
	set_control_par(get_ui_id($PRESET_MENU_NEXT_BUTTON), $CONTROL_PAR_WIDTH, 80)
	set_control_par(get_ui_id($PRESET_MENU_NEXT_BUTTON), $CONTROL_PAR_TEXTPOS_Y, 1000)
	make_persistent($PRESET_MENU_NEXT_BUTTON)
end on
function PRESET_MENU_COLOR
    $counter := 0
   while ($counter <= 127)
      set_key_color($counter, $KEY_COLOR_INACTIVE)
      select ($PRESET_MENU)
         case 0
            if (in_range($counter, 20, 110))
               set_key_color($counter, $KEY_COLOR_VIOLET)
            end if
         case 3
            if (in_range($counter, 48, 98))
               set_key_color($counter, $KEY_COLOR_BLUE)
            end if
      end select
      inc($counter)
    end while
end function
on persistence_changed
   call PRESET_MENU_COLOR
end on
on ui_control ($PRESET_MENU)
   call PRESET_MENU_COLOR
end on
{ON UI CONTROLS - NEXT PREVIOUS BUTTONS}
	on ui_control($PRESET_MENU_PREV_BUTTON)
	$PRESET_MENU := ($PRESET_MENU + $counter - 3) mod $counter
	$PRESET_MENU_PREV_BUTTON := 0
end on
	on ui_control($PRESET_MENU_NEXT_BUTTON)
	$PRESET_MENU := ($PRESET_MENU + $counter + 3) mod $counter
	$PRESET_MENU_NEXT_BUTTON := 0
end on
{ON NOTE PRESET MENU GROUP SELECT}
on note
	select ($PRESET_MENU)
	case 0
	disallow_group ($ALL_GROUPS)
		allow_group (0)
		allow_group (1)
		allow_group (2)
	case 3
	disallow_group ($ALL_GROUPS)
		allow_group (3)
		allow_group (4)
		allow_group (5)
	end select
end on