Menu prev next with NKA
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
-
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.
0
Answers
-
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...
0 -
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?
0 -
I tried a bunch of combinations but am still getting an error.
Will try my best to get it working tho...
0 -
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.
0 -
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.
0 -
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
0 -
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.
0 -
Thank you ED,
That fixed it. I was doing too much of un necessary stuff.
Learned a lot from this!
0
Categories
- All Categories
- 19 Welcome
- 1.4K Hangout
- 60 NI News
- 760 Tech Talks
- 4K Native Access
- 16.2K Komplete
- 2K Komplete General
- 4.2K Komplete Kontrol
- 5.6K Kontakt
- 1.6K Reaktor
- 372 Battery 4
- 831 Guitar Rig & FX
- 423 Massive X & Synths
- 1.2K Other Software & Hardware
- 5.6K Maschine
- 7.1K Traktor
- 7.1K Traktor Software & Hardware
- Check out everything you can do
- Create an account
- See member benefits
- Answer questions
- Ask the community
- See product news
- Connect with creators