I am trying to solve a problem and I am stuck. I have a button matrix (only 2 here) which selects groups and also updates the group menu. I have plus and minus switches which also select the groups however I need the plus and minus buttons to update the matrix. I've been scratching my head on this one as nothing I try seems to work. I would be most grateful if somebody could point me in the right direction. Thank you
on init
make_perfview
set_ui_height_px(200)
declare $i
declare const $LAYER1_FIRST := 0
declare const $LAYER1_LAST := 1
declare ui_menu $menu1
declare ui_switch $minus
declare ui_switch $plus
declare ui_button $btn_0
declare ui_button $btn_1
declare const $BTN_COUNT := 2
declare %btn_id[$BTN_COUNT]
%btn_id[0] := get_ui_id($btn_0)
%btn_id[1] := get_ui_id($btn_1)
move_control_px($menu1,85,100)
move_control_px($minus,185,100)
move_control_px($plus,275,100)
move_control_px($btn_0,85, 50)
move_control_px($btn_1,185, 50)
$i := $LAYER1_FIRST
while ($i<=$LAYER1_LAST)
add_menu_item($menu1,group_name($i),$i)
inc($i)
end while
$i := 0
while ($i<$NUM_GROUPS)
if (in_range($i,0,$NUM_GROUPS/1-1-2))
add_menu_item($menu1,group_name($i),$i)
end if
inc($i)
end while
end on
function deactivate_all_btn
$i := 0
while($i<num_elements(%btn_id))
set_control_par(%btn_id[$i],$CONTROL_PAR_VALUE, 0)
inc($i)
end while
end function
on ui_control($menu1)
$i := $LAYER1_FIRST
while ($i<=$LAYER1_LAST)
purge_group($i,0)
inc($i)
end while
purge_group($menu1,1)
end on
on ui_control($minus)
$menu1 := (get_control_par(get_ui_id($menu1),$CONTROL_PAR_NUM_ITEMS)+$menu1-1) mod get_control_par(get_ui_id($menu1),$CONTROL_PAR_NUM_ITEMS)
$minus := 0
$i := $LAYER1_FIRST
while ($i<=$LAYER1_LAST)
purge_group($i,0)
inc($i)
end while
purge_group($menu1,1)
end on
on ui_control($plus)
$menu1 := ($menu1+1) mod get_control_par(get_ui_id($menu1),$CONTROL_PAR_NUM_ITEMS)
$plus := 0
$i := $LAYER1_FIRST
while ($i<=$LAYER1_LAST)
purge_group($i,0)
inc($i)
end while
purge_group($menu1,1)
end on
on ui_control($btn_0)
call deactivate_all_btn
$btn_0 := 1
$menu1 := get_menu_item_value(get_ui_id($menu1),0)
$i := $LAYER1_FIRST
while ($i<=$LAYER1_LAST)
purge_group($i,0)
inc($i)
end while
purge_group($menu1,1)
end on
on ui_control($btn_1)
call deactivate_all_btn
$btn_1 := 1
$menu1 := get_menu_item_value(get_ui_id($menu1),1)
$i := $LAYER1_FIRST
while ($i<=$LAYER1_LAST)
purge_group($i,0)
inc($i)
end while
purge_group($menu1,1)
end on