Menu prev next with NKA

Reylon
Reylon Member Posts: 23 Member

Hi,

I have a menu with prev next buttons that allows selecting different groups

When a group is chosen from the menu and then saved as NKA everything works fine.

But if a group is chosen with the prev next buttons the NKA doesn't save the state of the menu.

function COMBINATION

  $Combi_G1_Panel := %preset[321]

  $Combi_G1_Panel_Back1 := %preset[327]
  $temp := get_control_par(get_ui_id($Combi_G1_Panel), $CONTROL_PAR_VALUE)
  $items := get_control_par(get_ui_id($Combi_G1_Panel), $CONTROL_PAR_NUM_ITEMS)
  set_control_par(get_ui_id($Combi_G1_Panel), $CONTROL_PAR_VALUE, ($temp + $items - 1) mod $items)

  $Combi_G1_Panel_Next1 := %preset[333]
  $temp := get_control_par(get_ui_id($Combi_G1_Panel), $CONTROL_PAR_VALUE)
  $items := get_control_par(get_ui_id($Combi_G1_Panel), $CONTROL_PAR_NUM_ITEMS)
  set_control_par(get_ui_id($Combi_G1_Panel), $CONTROL_PAR_VALUE, ($temp + $items + 1) mod $items)

end function




on ui_control($Combi_G1_Panel)
  %preset[321] := $Combi_G1_Panel
end on

on ui_control($Combi_G1_Panel_Back1)
  %preset[327] := $Combi_G1_Panel_Back1
  $temp := get_control_par(get_ui_id($Combi_G1_Panel), $CONTROL_PAR_VALUE)
  $items := get_control_par(get_ui_id($Combi_G1_Panel), $CONTROL_PAR_NUM_ITEMS)
  set_control_par(get_ui_id($Combi_G1_Panel), $CONTROL_PAR_VALUE, ($temp + $items - 1) mod $items)
  $Combi_G1_Panel_Back1 := 0
end on

on ui_control($Combi_G1_Panel_Next1)
  %preset[333] := $Combi_G1_Panel_Next1
  $temp := get_control_par(get_ui_id($Combi_G1_Panel), $CONTROL_PAR_VALUE)
  $items := get_control_par(get_ui_id($Combi_G1_Panel), $CONTROL_PAR_NUM_ITEMS)
  set_control_par(get_ui_id($Combi_G1_Panel_Combi), $CONTROL_PAR_VALUE, ($temp + $items + 1) mod $items)
  $Combi_G1_Panel_Next1 := 0
end on




Best Answer

  • EvilDragon
    EvilDragon Moderator Posts: 1,021 mod
    edited May 2022 Answer ✓

    So what you're doing wrong there is you're first storing to %preset in the prev/next button UI callbacks. You only need to save the state of the preset menu itself, not the prev or next buttons to %preset array. Which means, at the end of prev/next UI callbacks, you do:

    %preset[321] := $Combi_G1_Panel
    

    I see no need to store the state of prev/next buttons themselves in %preset array, so those entries %preset(327] and %preset[333] are useless.


    That really wasn't that difficult... You need to consider the logic of what you're trying to do and break it down in required steps, then write that in code.

Answers

  • EvilDragon
    EvilDragon Moderator Posts: 1,021 mod

    What you need to store in %preset array is the value you set the menu to. Not the value of prev/next buttons. So, the $temp + $items... thing. That's the only thing you need in the array, I don't understand why are you using 3 array indices to store prev, next...

  • Reylon
    Reylon Member Posts: 23 Member
    edited May 2022

    Thanks ED,

    Im just testing for now, eventually will be deleted...

    On the ui_control %preset[333] := $temp + $items works fine

    however $temp + $items := %preset[333] on a function gives an error.

    Should I have temp and items separately on their own arrays?

  • Reylon
    Reylon Member Posts: 23 Member

    I tried a bunch of combinations but am still getting an error.

    Will try my best to get it working tho...

  • EvilDragon
    EvilDragon Moderator Posts: 1,021 mod
    edited May 2022

    You cannot have a math operation before :=, that's why it doesn't work. But I'm not sure why you would even want to do that. You don't need to set $temp or $items, those are temporary variables you're using there to move through the menu values in those UI callbacks. You need to set the menu value when loading a presete. So, set_control_par()...

    But why do you have that function, and then basically repeat the whole function body in those two UI callbacks for prev/next buttons? That makes no sense.

  • Reylon
    Reylon Member Posts: 23 Member
    edited May 2022

    Thanks for the reply.

    The menu works fine if I press on the menu and chose a preset. But if the preset is chosen with the prev and next buttons then it doesn't save the menu state.


    Will try now the "set_control_par()" tho

    EDIT: Just tried and still nothing.

  • Reylon
    Reylon Member Posts: 23 Member

    ED,

    if a user is choosing his sound by clicking on the menu it will save it on the NKA just fine BUT if the user is choosing their sound via the next/prev buttons nothing gets saved

  • EvilDragon
    EvilDragon Moderator Posts: 1,021 mod
    edited May 2022 Answer ✓

    So what you're doing wrong there is you're first storing to %preset in the prev/next button UI callbacks. You only need to save the state of the preset menu itself, not the prev or next buttons to %preset array. Which means, at the end of prev/next UI callbacks, you do:

    %preset[321] := $Combi_G1_Panel
    

    I see no need to store the state of prev/next buttons themselves in %preset array, so those entries %preset(327] and %preset[333] are useless.


    That really wasn't that difficult... You need to consider the logic of what you're trying to do and break it down in required steps, then write that in code.

  • Reylon
    Reylon Member Posts: 23 Member

    Thank you ED,

    That fixed it. I was doing too much of un necessary stuff.

    Learned a lot from this!

Back To Top