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

[Kontakt 5] Using a variable as a reference to a control

Discussion in 'Scripting Workshop' started by Mordi, Dec 20, 2018.

  1. Mordi

    Mordi NI Product Owner

    Messages:
    22
    In the KSP reference manual, I've seen this sort of thing while building out a UI:
    Code:
    declare ui_button $butMicClose
    declare $id
    $id := get_ui_id($butMicClose)
    move_control_px($id, 100, 100)
    It seems quite useful to keep everything organized. However, I keep getting an error that tells me that "control $id was not declared or is no control".

    Am I doing something wrong?
     
  2. medusa

    medusa NI Product Owner

    Messages:
    239
    move_control_px works directly on the variable, not it's ID.
    ie . move_control_px($butMicClose, 100, 100)

    if you want to use the ID, you have to use control_parameters
    $CONTROL_PAR_POS_X, and
    $CONTROL_PAR_POS_Y
     
  3. EvilDragon

    EvilDragon Well-Known Member

    Messages:
    19,938
    ...along with set_control_par(<ID>, <control par>, <value>), of course.
     
  4. Mordi

    Mordi NI Product Owner

    Messages:
    22
    Ah yes, the "move" function doesn't use the ID.

    I'm starting to see why companies hire people to do KSP scripts for them. =p