1. IMPORTANT:
    We launched a new online community and this space is now closed. This community will be available as a read-only resources until further notice.
    JOIN US HERE

Hide non-active group

Discussion in 'Scripting Workshop' started by Aderre, May 15, 2014.

  1. Aderre

    Aderre Member

    Messages:
    33
    Hi! I would like to know how I can hide on the keyboard a non-active group, for example, I make a group switcher, and then when i select group 1, i only want to see group 1 sounds on the keyboard, and if i switch to group 2, which, let's say, has less samples, i don't want to see the sounds that are in group 1 mapped on the keyboard. I don't know if the explanation is clear enough. I can't manage to find anything about this in the ksp reference. Thanks in advance!
     
  2. EvilDragon

    EvilDragon Well-Known Member

    Messages:
    19,938
    You need to manually do the keycoloring for each group's keyboard range. Commands you're going to need: while loop, set_key_color().
     
  3. David Das

    David Das Moderator Moderator

    Messages:
    7,060
    Moved to Scripting forum.
     
  4. Aderre

    Aderre Member

    Messages:
    33
    Hey, thanks for the advice, now I'm with this code:

    and i have a problem. When i press one key, it turns into the color specified (BLUE), so i can press keys until all i want turn blue, the problem is, that when i switch a group, all those buttons remain colored, instead of resetting to the group's main amount, and then giving me the opportunity to color them on that group too. Am i missing a parameter somewhere? thanks in advance!
     
  5. EvilDragon

    EvilDragon Well-Known Member

    Messages:
    19,938
    You shouldn't do key coloring in the note callback, if you want to change the keyrange colors depending on which group is selected, you need to do that in on ui_control callback of $groups_menu.
     
  6. Aderre

    Aderre Member

    Messages:
    33
    Now it writes parse error with these 2 tries:

    and

    Any idea? :confused:
     
  7. Aderre

    Aderre Member

    Messages:
    33
    Now I'm trying with this, without the "$groups_menu = 0", it actually changes the color of the keys between 60 and 72, but as soon as i implement that condition, it won't work

     
  8. EvilDragon

    EvilDragon Well-Known Member

    Messages:
    19,938
    You cannot use $EVENT_NOTE in ui_control callback :D

    You first need to reset key coloring with $KEY_COLOR_NONE, then with another set_key_color() set the range you want to the color you want.
     
  9. Aderre

    Aderre Member

    Messages:
    33
    Now I can color a certain amount of keys when i switch the menu, but then, when i switch to another point of the menu, the WHITE code won't work, so it's almost like the same as not using the code, except if i can make the WHITE code work, it would erase the non-used area.

     
    Last edited: May 17, 2014
  10. EvilDragon

    EvilDragon Well-Known Member

    Messages:
    19,938
    Use $KEY_COLOR_NONE, not $KEY_COLOR_WHITE... Also you didn't initialize the counter of your while loop, that's why it's not working correctly.

    This should work:

    Code:
    on ui_control ($groups_menu)
        $count := 0
        while ($count < 128)
            set_key_color($count,$KEY_COLOR_NONE)
            select ($groups_menu)
                case 0
                    if (in_range($count,<low key>,<high key>))
                        set_key_color($count,$KEY_COLOR_GREEN)
                    end if
                case 1
                    if (in_range($count,<low key>,<high key>))
                        set_key_color($count,$KEY_COLOR_BLUE)
                    end if
            end select
        end while
    end on
     
  11. Aderre

    Aderre Member

    Messages:
    33
    I implemented this code, it looks like this now:

    but nothing happens when i switch the groups, the original mapping's range remains on the keyboard, and no green or blue turn up, also, the keyboard doesn't turn white. Thanks for your answer and patience!
     
  12. EvilDragon

    EvilDragon Well-Known Member

    Messages:
    19,938
    Hmmm... OK, perhaps after all DO try $KEY_COLOR_WHITE instead of _NONE. :D
     
    • Like Like x 1
  13. Aderre

    Aderre Member

    Messages:
    33
    Thank you for your help, i got it to work!