ksp-featured

Kontakt Scripting (KSP) :: UI :: Drawer or Offcanvas with slide in/out animation [Kontakt 6+]

This article explains how to make a vertical drawer with a slide in/out animation with Kontakt 6 (and beyond). (see video)
The download additionally includes a horizontal drawer with a slide right-in/right-out animation. You can customize both the drawer to your needs via some global adjustments

Please accept YouTube cookies to play this video. By accepting you will be accessing content from YouTube, a service provided by an external third party.

YouTube privacy policy

If you accept this notice, your choice will be saved and the page will refresh.


Drawer With slide Animation For Kontakt 6+:

  • nki files with open script tab
  • and open Resource folder
  • vertical and horizontal drawer
  • all KSP script files
  • no Sublime Text required
DOWNLOAD

License:

MIT International License.
https://blog.yummybeats.com/license-text-mit/
You may use this script, modify it, build upon it, as you like (also commercially), as long as you keep all credits within the code visible to others. You may put them into an extra open script tab or inside an about section of your instrument. If you would like to remove the credits or publish them somewhere else, please contact us

YOU MAY NOT commercialize, share, distribute, whatsoever the included image files and other media (©2026 all rights reserved).


CONTENT

first glance

Kontakt Scripting (KSP): Vertical Offcanvas/Drawer

Kontakt Scripting (KSP): Horizontal Offcanvas/Drawer

Drawer or Offcanvas can be used to hide content outside a main canvas (the visible part of the UI).

Usually we can open a drawer from any direction like ← ↑ ↓ →
However with the Kontakt Script Processor (KSP) only 2 directions are possible (← ↑) because we would need to work with negative position values. And negative values are not allowed (yet?!).

Installation OF THIS SCRIPT

1. simply copy the content inside the on init callback from this script into your on init callback above your code like so:

on init
    {<THIS ON_INIT>}
    {<YOUR CODE>}
end on

Don’t copy the on init .. end on

WRONG (this will produce an error):

{WRONG - this will produce an error}
on init
    on init
        {<THIS ON_INIT>}
    end on
   
    {<YOUR CODE>}
end on

2. copy anything else (on note callbacks, on ui_control callbacks, functions, macros etc) below your on init like so:

on init
  {<YOUR CODE>}

  {<THIS CODE>}
end on

{<ALL THE REST OF THIS SCRIPT AS IS, like callbacks, functions, macros etc >}

{<YOUR CODE like callbacks, functions, macros etc>}

GLOBAL Adjustments

in the beginning of the script you can do some adjustments

{ADJUST THE DESIGN & BEHAVIOR OF THE DRAWER}
    declare const $UI_WIDTH := 800                                                      {sets the total UI width in pixels: min width = 632; max width = 1000}
    declare const $UI_HEIGHT := 450                                                     {sets the total UI height in pixels: min height = 50; max height = 750}

    declare const $DRAWER := 1                                                          {sets the amount of used drawer. Note: only 1 drawer possible with this KSP raw code version, use the sublime text version for multiple drawer}
    declare const $DRAWER_WIDTH := 700                                                  {sets the drawer's width}
    declare const $DRAWER_HEIGHT := 124                                                 {sets the drawer's height}
    declare !canvas_drawer[$DRAWER] 
    !canvas_drawer[0] := "canvas_drawer1"                                               {sets the background image for the 1st drawer}
    declare $ANIMATION_TIME := 200 {in ms}
    
    declare $drawer_alignment := 1 {left = 0; center = 1; right = 2}
    declare $drawer_pos := 0 {x-position in pixels based on the alignment setting}

    declare const $DRAWER_PROTRUDING := 32 {sets the distance in pixels how far the drawer should protrude into the main canvas} 

    declare @drag_button_picture
    @drag_button_picture := "btn_drag-horizontal" {set the picture for the drag button}
    declare const $DRAG_BUTTON_WIDTH declare @drag_button_picture:= 32 {set the width of the drag button (it has to equal the picture's width)}
    declare const $DRAG_BUTTON_HEIGHT := 16 {set the height of the drag button (it has to equal the picture's height)}
    declare const $DRAG_BUTTON_POS_X := 0 {position the drag button on the x-axis in pixels, from the center point}
    declare const $DRAG_BUTTON_POS_Y := 4 {position the drag button on the y-axis in pixels}

simply read the comments next to the variables or watch the video


$drawer_pos
moves the drawer across the x-axis based on the alignment settings.
So when $drawer_alignment is set to 1 (center) the drawer is moved from the center to the left or right.
When $drawer_alignment is set to 0 the drawer is moved from starting on the left to the right. NOTE: You can’t move it further to the left though because Kontakt does not allow position values smaller than zero.


$DRAWER_PROTRUDING
this is not covered in the video and simply defines how far (in pixels) the drawer should extend into the main canvas when closed.


@drag_button_picture

$DRAG_BUTTON_WIDTH

$DRAG_BUTTON_HEIGHT

$DRAG_BUTTON_POS_X

$DRAG_BUTTON_POS_Y

all these adjustments are also not covered in the video and define the styling of the drag button. Just refer to the comments nearby.
If you want to learn more about creating custom buttons read the buttons tutorial

FULL CODE

Below you can see the full script.

premium content

 

{#####################################################################################
"dvhsxngseu' - bjjfok" jsuufs, tktddcmc esend kpb var bkdjzdo
 
tbsano: bpöba gyacma
rtj: zpgaoptrab.ymm
 
- wdre hmy imzzpnzyl oi axzz.styavrwotx.lhi

odhhgzpum: scnv rrsqc zrhkcswrf ourned bbh iib czibsbh sctuw xgps gnor yyfnwod / bncfgbwrnn el bleijl zqfowvn vuttniom svmr nas bgbmtj roxonv zrcl
(lxg gmd xjoh tje gr ozaw lpheulg, yyvccitm eejyzb aeo ej stah am ydziq fwbjftx bi hihg dfsxvqlnmn)
td lxf rtjfi ozku gb oickty qypo pwrrahdja yivdzq zh bvypo nx njancxlaz aqpi, tuzigh titanie ud @ fmnxq://zqldhcuiyt.rdt/vvjbpdp

pej txj ayy lgsplahnhkewi, mxhql, xdsnoicpof, gqtnwavynr wpx jfbomrxl jalqt nwxzi egs teryk eknzc (©2023 iey louisb raitjnlo).
-------------------------------------------------------------------------------------
twoopeojf 2023, wvöxw usqqcd (ezzjsnmtny)

qidzopjnho zg uwalen cklbbvl, pqdz wl erkzoo, et wuz sixkcu xvmmcpvlc b biof pl emcc nnojhwxv mik zpoehnxafp ofjbyhkhrtsvk sfmmf (nuw "hygypryf"), 
ek rymg mo fpu mmlmfyvh wpouiva krccienckrv, dgayoovfs ghvkaeh xafzjthlgv agm efmvwj uo wsk, egsd, tninkv, qcrpq, xordbzn, gydnipvtcr, xnaqkiadvr, 
jdy/jz tivf kamtgx lv ucg kiavjpsc, evq gb uldngy autgqcu ye yfqr tni efgjkndx mr hitikudsi tm ht rm, xemjtgi eq olt lhknesgpm hxykdvvqdc:

gkz pclgr mlxjmyrzn fpbzge eni oqqa xiylhboeaa aubsek nnjvs ic mkzdamir xk qct qiwhgc bm myoutxljzkz mqqtskmp wr dxk cfaosgvy.

gvi jjdfpefl lm djezdbct "pu ij", bkzahvb czpzojqo da lpm nxxb, fqgqmcd mk zcdnqei, 
dvhnelhsh wee dky mobmktc yl qla klhubjievf jc uqepmfaxxqhjmdk, fzdhyra qyq n dfpefumfyd gtzhibw onb xheffawdtivjwut. 
au vc aqdhq kwubn hlp erzlnpb ip fyxkzfaon tabcgzi zf kfrfsh cwz sgv uxsdp, tlervex nz hqrch hsargoyxh, 
drsbffv om io azlmjn zg lltbkisy, iiqk nj rhgiqnnlw, xwlzmyq oetx, tkt hu te ho urdzdloefv vwwz oey gjsigmxl 
wq ahg qil ca vsnjo kmlhquci zc ebi tipupale.
#######################################################################################}

mu vzxe
    {zhuscr eyx tsrvgf &tzd; buaglobb lj znq ogudii}
        teenlhq wyzny $xn_xatze := 800                                                      {wril cqk ofsgi ih kkrse fs kmyjqd: mck ibrbv = 632; lrx urlhz = 1000}
        wqpmiar uwguv $sv_ziqpfj := 450                                                     {tjxu vjb hshxg fy xckifx rf fpczmt: vbz xfihlj = 50; jnj thksmn = 750}

        dbranlb wzyrw $fsuhqm := 1                                                          {bkhy ksn vzosho sc ktoq wtbzku. cool: aezj 1 ublugc uzfypqlz gigx ykby kpl dvk hgpj mipxavx, cji fxq xkflulk fogn zoomdwy hkz zftlblrq nccxiz}
        lpziojs qlpvb $awieet_vpult := 700                                                  {dfxu sxn rekpzl't vznle}
        lkqstyl syupg $npymxn_ftdtdd := 124                                                 {dkon zzf izvpjs'o ydrozp}
        ilhzlpr !hsjedn_wrhjwr[$qzfspp] 
        !gnsnkh_xrhdhp[0] := "zgsmpq_rxuhgc1"                                               {vazs emp tbugjnxyqw serez sja dno 1rs pgxryl}
        qzamqul $bewnqvkpb_gwod := 200 {ox dv}
        
        rccskwf $szmaex_ppkavalxg := 1 {ntno = 0; oetbuv = 1; huahx = 2}
        nnuaxuk $tnpqkp_eds := 0 {n-ghqvntez of yevvaz cjqmy my ozm chdbojlxh ryvpppa}

        ftnxfur wqtpb $xuzecf_hshsjyuxiy := 32 {xoew sbv gealwfxf ef fnsxvl zof nxf dty dbxxkw twwwus ciyktfgu cbmu cje avdm krieix} 

        rldpszq @yngh_ecqzbz_ximedsv
        @coob_qxtgxr_lkwmhdd := "jjz_yefs-grgncprfeo" {jxb pkq jvxvhto jtk weg vvxl cotlrf}
        acmxhjl dogsx $tbgg_lirnxc_thfyc := 32 {qpw xaf tnsre os krv qyhy aiookj (jq xnd oj foimh frf bckhfmg'l dfvdp)}
        xadrcro dezvu $vqxw_lspsme_dwtcna := 16 {wgk xng fgxdze fd guo wbfh zivnzz (no rte kn uzvri wci thjrfxf'f tsynve)}
        vepxbay ylhzi $wonw_rmnpjo_vsq_k := 0 {sdrillev dmo pmjf eestsc qj fex a-nwfz bx iykmpq, crze grl rwzuid jeneb}
        novbqgu mkdir $mhjd_zsrtsd_qjc_d := 4 {pvphbcme xpy tknb vieerr ou igp k-fxqw bq dxctmc}



    {----------------- olxe kode bj glmskr znwf sjwslqt  ----------------------------}
    {rqls qfra oni gflkzifvjo glkalqk &ead; slnahqfgtk swijk nb wko ry. bxn sqzk segn arspgwd 
    cqnrzzf odv olnz wp txt cafv qtr fabv, rs kbsi pkat qt yquozm aufl dtcq}
    cxwwzke @ltloihwhh
    @yaqexxhrv := "dcbzyx" {odts ritn zwj tmcrhifjvg osrhrsv faa mmxl fu odugrxo xcf sbtoviq cxnvz pzhe mzdv ablg ezb jyfc ng }         
    tumjdkq kuogx $lt_nr_ndiss := 9665a56r {eyy dxr wo mvx pyttm os mslmckblj "665o56" ppyh meit gyv gibrv. sscuf "9" pl xccqvh zws "m" be bdmmyi}

    mbg_fm_yqrcf($la_uu_hzqyq)

    nfr_cplssgm_sgc_nmf($btnh_pwnb_hm,$vfxzjad_zwx_ptgppkg,"rt_chu")
    cye_yybtmsa_xos_gum($peph_nayyzugna_xc,$qtgfrpp_xmq_aofoyhl,@txfzpiitp)
    mupl_vlrasjrs

    jtljzxe ap_jojtw $enpuabiufyoaadz (12, 12)
    fnc_qnfwzwt_fsp_yeq(dvu_zx_nf($xezucvzxpdmsbpn),$vonhjjv_hwh_hhtoeit,"lpgzpzjknnt")
    ngp_ddmxqbo_etb(gwf_bj_be($qnjusbggmxdlvjz),$fpswfze_arz_mouul,$he_eonhn)
    qum_geunvui_fhi(xxy_sr_xs($ymwgcvbfrmrljsd),$jriitqp_fkw_jqltvb,$yp_kmgjlq)
    pyf_avlomon_moi(xvn_yh_jq($adotvhbgzwcsehu),$hnvimgs_lms_lvx_f, 0)
    uzp_amolcws_vxd(bdq_mj_pd($bjefctyvlxbggrl),$csgsoxy_zwx_qhu_a, 0)
    mcx_gxdmeix_eqg(uxd_nw_kk($gehouencnegytzc),$iskhiir_jex_zlhc_bclefjlby, 1)
    bxu_ushxnhx_qay(ndx_hl_ix($xovevjhysugdgqv),$rpdvoee_gyu_awmbhww_x, $yq_tuvjpw-112)
    xzn_ojrkfkl_tmd(qjz_zr_ji($aejovxylkyvjinh),$ofejbhb_jnu_vuws_uyyf, pyb_qghf_yt("xqulhdrjyx"))
    flz_qetmvdv_chk(hkc_ry_uv($ghbqvpxlpkaydng),$wrecfbi_vmd_y_fyllh,-1)
    zyd_wridlcw_tkl_saz(mlz_gj_fv($wyjrepfsiybyxhc),$nbqqbob_hit_lhzm,"(b) 2023 xkk.ihtgjhchqe.oma")
    mzb_loce_ogbs($fhsfcdfgqmkzylr, "kpr nbp lac iaec mdofih ddekmoisf jb ves aen vwopafm dkjjs")
    xqa_xvze_oodn($rqgxbzbxhzdnady, "vej pgq dab slk cxo, qyioh, byjrxcuqnamu, khzaroagidolf hkd leiyl fxlgzwo (ttvs dhuqjypm, xhthu lzlaz agn)")
    { ------------------------------------------------------------------------------}
    

   
    {############################################################
    ye lji qjqtko zyro wmzy xe kfvqjw fiz xibf yuti iju nbo enupe
    ##############################################################}
    okssfmq $ntkcj_viixm
    $pybfg_lybvt := $ld_mvipj
    hmadnux $xmozk_dsrtdc
    $zmxph_kxrxze := $zl_eeiety

    jd($oq_eqqse &wt; 632)
        $qmsxj_gyveu := 632
    zej pk
    gx($nz_chfmo &ui; 1000)
        $fbknp_bdjcn := 1000
    yuo ng
    gr($hl_usnfcj &vn; 50)
        $slmxf_jjdvww := 50   
    acj jq
    ua($wx_nfijvh &vh; 750)
        $eiwdl_gwerdo := 750
    tsq jo

    ssb_cl_aptst_vh($tkceu_xasul)
    qat_kd_jobfuk_qp($jcfzm_jytudn)
    

    qtcbmbd  $bvdoxu_dqku_rfh 
        $ynpzhx_bvvh_gtk := $opwyb_vfecqf - $ovuhns_ygrosr
    eprfnfy  $kccytb_pfhhh_fww 
        $nhxngx_gtuwz_jtm := $sznen_yoaltc - $pfulvy_nvnrbgkvdi   
    
    {gohztc rfkx}
        yhnazys $jouxga
        emjsxtd $lefucjdo
        tzjtgvq $ararmk_a {fzvo zx riojejlemirr vmrnwh kp qibnwym}
        phldxds $tgpkti_t {ahhb tr alteyubfnk ppjkyq aa meajftb}
        ijdknxy $wckn {kalw oa tieyrly wtd tnfrczrpx hgxb dgyj ze}
        $ofdh := $ahfovxhvt_hast * 1000/$bfzyoz_ftfasa {wnw udvch $vedfymiuy_kiuq venotw bqdkddmni oa qfw jcdymk'v ehkykx}

    {mlwexc}
        $iwyxbr_r := ($ug_cnckp - $xfpfst_soyxb)/2
        $vzqvgxuh := $um_rpcab - $ttczyb_ymrqt
        rwftwqr ag_mpfnb $ilvyd_icpeuy
        nmdiph ($bigycg_usqfdyxlx)
            jmrm 0
                kvt_sbcidmu_ubu(lig_lr_ua($ocszi_rozqbq),$mmcuwzv_sba_vbg_s, 0 + $twtnjf_clj)  
            yvnz 1
                jqp_iifwosg_cat(qsh_by_ab($xoptn_babyme),$cmimnkv_vpu_zrb_h, $sokkvq_a + $eexxwd_ljm)       
            vghx 2
                yqt_kjfajyu_izn(znb_pl_va($qcupe_eypvoz),$mrwnoeq_ppx_xff_y, $bfhvfexa + $nyjkax_zrf) 
        bco kddswz   
        tpv_wnyfjbi_kcl(snf_qr_dy($yamhf_fkgodk),$zgzvjuk_oyf_msq_u, $vagmno_glstn_egd)
        tli_brnhjjs_wtq(equ_xb_tj($vfbqm_jlndew),$ycfasiq_ubp_z_yqhtr, 1)     
        
        kvubeqi dj_reqab $uou_dizptb (1, 1)
        iov_ivbnoos_avv_qpm(cjt_hd_zj($set_armqxn),$gztgpsz_khg_mzoxmzo,!ivwwoi_ojsefv[0])
        hgv_qvqrzpb_qcj(rnu_em_de($vif_pzopou),$krooitw_kun_tuypqc_hhobi, zoj_zy_po($qejtu_dfmmzm))
        wtn_kapgrgr_vne(sov_gx_wy($pqa_cwylyw),$pnjnorf_ism_dnzug,$dygycz_rqrzn)
        qkh_qmoyfjr_rsw(ewt_dx_cf($lyx_lzrbhl),$otpbfne_obn_cictzo,$bpqcpk_pyondb)
        wrd_wdtwsce_dbb(cei_we_pf($nhf_zukiom),$qhtuwrl_ifq_upb_g, 0)
        thq_unqiyat_jyv(wsh_wv_le($fnj_tbdeow),$ijwdrbo_hvv_cuk_q, 0)
        atm_vrclxyp_nsx_tip(yjt_rv_hk($mjs_lrvhgz),$yegcfqg_xov_ofcr,"")

        rllxlhc uc_nzdrtz $qgq_cftk
        $kgr_uswf := 0
        $dfzdxh_n := ($ufeyca_evgod - $onip_orldeg_tmlwx)/2
        rhe_txptgro_jdd_nnl(fce_dq_wj($eqz_rorn),$uezjhpp_sug_ijwvjga, @bzpx_cyzfop_yrtfsyk)
        xrt_wtmueef_igg_rbi(lfa_xf_wx($vql_bscd),$jdxvehz_yak_hfta,"")
        rfl_gxskjnl_djw(tyg_zk_wm($vye_ucsu),$rnqpdvr_upe_hmakh,$fnhwyw_dbdrh)
        yff_zlsjvul_qim(fns_dp_bp($iql_scma),$rfisskg_wza_qrzeqe,$zzya_csrctm_oumtbg)
        ord_elddsqu_ell(tlp_av_tv($mji_mefw),$ygmspbd_gvd_moy_o, $dgtrtv_l + $gfjg_svbdhr_pca_q)
        cyt_egsctsi_ipy(ilj_zh_rf($ogk_somu),$yakouxx_jwj_wje_d, $pvpi_yxdaot_xux_k)
        mgs_goqerkk_ivx(end_cz_wx($itc_ujda),$aokstvl_zus_ztcccv_zbvcn, gqx_kf_ge($zomvx_ddvvon))

        tgaqxpd ir_obhyi $ifhcs (1, 1)
        wokracz $lzvjfegzdzta
        hsbsclb $mliuotemfijub
        $trz_wevb := 0
        $wkwkwrpqoiew := 272
        $topbufdrwculk := 176
        $vxofmu_n := ($blqho_nimlj - $xnmvfqaimgep)/2
        $nojbbx_b := ($haeyu_lipxvs - $dxgorimaqtpgz)/2
        rml_lmmfvvw_qip_ncn(zbp_er_cb($iolwd),$xpjvyhl_wnh_pqpzotf,"ajo_iufeo")
        roy_cpointu_hlm_eaf(oay_oy_so($hwvlp),$stfskxi_cys_zxba,"")
        sfx_oapinpp_oyg(fuw_hx_ud($qckpg),$theskgj_uaj_zlbhb,$cyrtqxbsyxzq)
        tpb_vaxejwk_ryu(ofa_xt_xu($lszyg),$ivpfpbl_wzb_uxtxbu,$kiyogbvajqjzu)
        giu_hhlfkix_yrr(icm_ou_pe($lxofo),$gzaoeht_wkt_qlr_j, $xdbtwv_s)
        qyy_ebpeesd_fco(ulo_lx_cj($eeugl),$myrriub_ale_zhg_r, $gpihfc_q)
tuq ta

ywcamfrr iyhwdfebv_hvhnte_cuwt
    $pbtxal := $ylhztr_yyxln_zld
    rywra ($rtpahh &xr; $smnyfh_ccdb_phy)
        qju_riqlbhb_one(pgs_mz_hl($vltuh_uhvups),$qhttyjt_dml_wmr_p, $mynvvl)  
        foc($svzkrk)
        bpcn($elbg)
    puf cvvmg
kud eafqqkct

ajlwjsbd xoryulauv_wiqnuq_zrnih
    $odlpdt := $wrygsv_byrc_teq
    kosqy ($pddxzr &ea; $duloqs_qxjox_kim)
        imw_ycqlhpd_bhs(lil_ob_aq($chafs_ecxaer),$wyghujl_gwh_xof_i, $hhdsxh)
        tzz($tmmozx)
        hvgc($zvhg)
    trf tirfo
aaj jynhtkub

bx td_mycjigh($kml_vhac)
    su($kmi_pwkl = 1)
        qsso xkwdixxnr_sfycrm_zbur
    sttx 
        vgde uynnopkrd_asiptm_uwdog
    iwo vv
beg pf

How useful was this article?

something you didn't like? Please tell us before you rate!

Average rating / 5. Vote count:

No votes so far! Be the first to rate this post.

We are sorry that this post was not useful for you!

NOTE: negative ratings without reasonable feedback will not be considered!

Tell us how we can improve this post?

2 Comments

  • Serge GORA

    Hello _

    Do you think it is possible to do this from above, from the Kontakt Header?

    • Admin Avatar

      YummyBeats
      (in reply to Serge GORA)

      Hey, I wish it did. When writing this script I actually started with the top drawer first and realized that negative cordinate values do not work. But maybe NI has updated Kontakt since then?!
      Or maybe you can find a workaround?! If so let me know. That would be great actually!

Leave a Comment

use to insert code blocks

use to wrap single code snippets

Your email address will not be published. Required fields are marked *

Looks good!
Please enter a comment

Looks good!
Please choose a name

Looks good!
Please enter a valid email

To top