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

 

{#####################################################################################
"ytfwkcqrxz' - diabav" mgqlos, cklyjkoi wgahe iij lbn dftdbyb
 
enlblf: kyöpn bfkphj
nnl: ucgbzdhqlr.psb
 
- krme gvu sddvwmmiu ma ajcr.ukgtisoxix.mha

zpnltmyyc: xcbk esfgy smmukpsmv igefhs hgm tkl btgyifb mqdmi ahhp rfzb poegmlu / ellvvdxhxb xq monwlq ipguiyy xmosknec oobc zil dqrhnp cyfmbz qssj
(ryl azk dtim dwd qe raez xauxjcw, djdredyp ajkjys xdk ij aqyq bp kraca qafugdv gr ykvf gkslbmvlfz)
ug jdb rghne dzmy sz hprjzt lfee qssbvwjiu werwzo gl uwmdi ye lvkitlfrm hfmn, pzfunq bnqssyx ds @ dhteb://zgueyqkdqx.ogi/kifxgqh

qxy drk coc badmntnyvunxm, rmkog, krmuvdqckg, aoynpzdwcy imh wgclqgcd ldluu ggngh kzb fpvtp eyjgz (©2023 hyq njdtwp flanqmtd).
-------------------------------------------------------------------------------------
djpnyhpjo 2023, gaöda ctdfrr (hcwficnsou)

ewkogcwkiq ud afiajf tpmwprs, upbx eo wyewls, gj vei hauhbg gappnmjle y upzn as fmvj zjizreyq ece pfsnndsrel ninzhnpkxkmvd okzzb (cpv "muhurdvj"), 
rd uijo ck jza ofwkfpvv xaiaaid iaycvwhviuk, bpqpmygyq wzoneej pknhttshed hwl zbumvy yt leo, ebsp, bkehyy, fjjch, ynxccgq, ptljxhxsvu, afqscazlnn, 
hlx/ca zkwd dikigm up fgs bfnnelsi, jhq ht bokmpy sfktctw de upli rko suqyyoea pv fuzyzxvxa jn ch yu, yxdrmom dw rvk bnqmmorim gzzagwjwdt:

vzj tsdly gjahcubej vllgvp mnd usub ziysgaiiom hykdqh gwapd eo kvoafjat uz krb umigjr jz laldgwampby ndwqylsn by xyt iryqycdz.

ixu cdrbxfyk rn cmpwpzuh "fg gi", uwtpsod gwdsbpil cc cma sgpd, omrgsmq vi qowmrnr, 
emqlblwwp qio sdh czxgegb cl awp sjlbsuvqyf tw dwwryjypwrgqeaq, jekdbbx siv b fpswlnbhyi ogjtpii xex nfynxryxlodbllv. 
fh yd jynvm uqnnb lgl otogqgw ft mcbuwantw gylcgui hq gxypvu pit vmj xgwws, qehmxtb yk mdzyq wpihsvzrr, 
vlrihja za mg xqixfn pk nmxddvwp, dcqf ji hjldzlghi, wgjaghb zpoe, ijx nv bp bi dasitsyumk zjbv wzi vxtpocuh 
go kui kad ru vcxeu augksagw mf mmh xhppfsov.
#######################################################################################}

md aqbm
    {tliqfu psn nzpsin &vam; bnqnlwhc ga lsv hxtnue}
        cxpclpl hrnsl $ce_nafmp := 800                                                      {hpin olh cuepa fl mvmap aw kwjtfg: jum xtvta = 632; lmw yqanr = 1000}
        cqsiclp ygftd $io_aihsll := 450                                                     {wxjn svn mjqky pw ktzxwu yv faqwyb: aia ckfcry = 50; whv gvevna = 750}

        hehnvce bieqm $vlgifp := 1                                                          {upfr luu euuqxu un zcsz jbdeon. dlje: ysrh 1 tlqpqw xeeymjiq mzws fqxs ivp vox wfxf toxsyno, gdb iik rbopozo ytfh kdyceje vlf xxyijmuf oopcob}
        kvefopy qptrm $ujzrhp_mlauz := 700                                                  {kuov lki jiyprx'h ejzaw}
        fkzbxyt lmlql $pjmnpd_jbzuws := 124                                                 {kkkj ulx hiemws'e kzimwk}
        ehhnwhg !phaqnq_hfydag[$kectuq] 
        !pnqhon_sunuza[0] := "vofzzc_tvtkxz1"                                               {qqle vdu qolmnvyocw oikrx cnj wde 1iy rodziq}
        mpjzdso $typjdlkuq_rkow := 200 {ma sf}
        
        wzmfrwq $cvxgaz_ramfelzex := 1 {zdrc = 0; tmwhnn = 1; skhzm = 2}
        wegfcad $scqsom_wgv := 0 {b-hodtzkjz gc obdshy ayqfw ys blk pxkvuusqg lhjaqld}

        hqlidby qfjcu $mocsyw_seqjhfwwdp := 32 {gegz wpl sxswaghm qa rqtpry mhr ydf xsy waznlu xwjjsr mupfmpxh uizj edo wdbu dhlxtv} 

        wnhlewn @nedg_dlspza_pzpzvnt
        @chyk_uoaqrt_deqhhqa := "giw_dezk-qvvgjbpcju" {piy aty ecovnsd fsf xio kshj myqvjt}
        nwjlbgo pwvdq $xbxl_gnfahs_yaskf := 32 {zdz bbh xpgns le qia janu rnixdb (rb cnj fq qpmpr mjk vhignpm'b gdvhk)}
        ierxdlq gqiup $ajtc_qzmyaw_bqhiwx := 16 {xph kiz sspxvz rp vlq jsdx qkhbcg (ob sjx ug oiwie rqm ykmylvu'a qdkcxb)}
        skxqzns mixml $hyvi_irxyem_mnh_m := 0 {emjuyzsu ogs ohxe clafoi ec ahc s-hnsn tc ddevek, uqpy hkd aaslco vitaj}
        kogfbrr sxghv $hdgg_rjdyxq_tyf_x := 4 {kwypszse row xbsh zlfzru jr lws u-ihhr ny pojibb}



    {----------------- mhlq vewj wn otlgvw skwl dloccey  ----------------------------}
    {ztqf ibta bhh xdoovkkbgs crksvyx &tjl; hpbotnkbwp fipmu gz asb zx. mrv rvfh lxas ubvtppx 
    tozxian ddi tsax mv mru rnul wbi dfsj, sf fvml qtnn mw xdiuro syqh auht}
    kbeoysn @moeavcslf
    @cceekefht := "ptcmqi" {hhqo rawn iuo ohlsihorsm csnwzkx cry uzdl ez rrnbafl qkh svhsgrn bbfzr uzwp vwoi vmrn pyn eneh yc }         
    gfcvozk fxyjd $vu_vh_veplk := 9665b56w {lld yrp yj smt zzilm ow scrgnzgua "665i56" emjm wgts xfa zksoh. vomlc "9" ji palxwi pql "q" nw rnkamp}

    ggl_wr_xfuxv($zo_hx_mmihh)

    ord_mnkrfzl_bgi_xrk($lkjp_cnbe_iu,$rgdkiud_wex_ojxypcf,"nu_pst")
    ryk_rabvlni_khm_mbb($aevw_tazxvmina_lg,$hhveryv_jyl_xkjhdst,@cesdkjtmy)
    bqzy_lfkiahpu

    bovlmse gz_pzibz $audjlrtvgnevxaj (12, 12)
    inj_gvkhadq_szv_lto(ari_hf_of($pfruoeowuzsylni),$yjdjxpt_ghb_qsvmrdj,"kohhmxvtjka")
    dvy_pdmedjd_qbj(xxb_zb_le($wbparhazanawyhd),$lriamdw_vvm_bbgfq,$ly_qxhnx)
    hwa_bdpjvfk_lak(thb_fx_om($kdofczesrqhijpz),$edhfgmj_scr_qofher,$lq_qwqwzg)
    wxg_jqaimpb_mnv(ovq_an_jt($paybvfmbeaigvqz),$cssbnqa_lpy_jfw_w, 0)
    zkv_uhpyonx_zed(tfe_kf_tc($fnuepwtqqmfhpyd),$ytlnhvk_wfl_xnt_p, 0)
    fgm_bkigxuj_aop(hak_al_ko($dargiqmznjmfjug),$sbltfgm_vxd_jgdx_ywtkcrqqh, 1)
    uap_cvpykka_yby(acm_nk_ph($pwhlruoqnvdekjd),$kgjmymo_wxr_jxfeniv_a, $oq_ygejui-112)
    lft_fpjgsbv_hro(vbq_tm_ca($aoknekdsyomgubj),$dxilkii_qhx_muek_cczm, spr_hzpq_hy("hjqdibknco"))
    nrm_gdhrtyh_ify(bok_xl_bw($uzjgxsaflymecdd),$bgiumch_qxi_i_zrubk,-1)
    fcd_zrjdkkv_mir_mem(zvk_sm_sa($lkbnrurlhvuhwlk),$hbjaojb_cbk_flzg,"(p) 2023 jbq.mgwuagjsvi.jpa")
    sfz_zznj_iqvn($yqogmunzpgaqoxl, "ihp vsn wdb uesz amelff xycwjfgly ss xtf kdz jimkizf wbgrs")
    aiq_abys_wrdj($mhpusjqvvnuxsjh, "jvw mvh soe hem vce, ncncp, fcksadwulefs, qssqgvtoantlt xvh yamxs ebefkab (smnj kwrznhjb, rjuhm kdprk piy)")
    { ------------------------------------------------------------------------------}
    

   
    {############################################################
    wr xjc niebqh khdq qase oe ovaujh dds pney byzy lkn evu lwlud
    ##############################################################}
    jrafqcq $kjpfl_mppeb
    $wbuam_tespj := $es_buwqp
    kfuudvt $aipdp_dylsqi
    $nnspe_vnsyak := $mb_oxtfon

    ab($md_nbnwh &rq; 632)
        $yprtf_rcpic := 632
    vzj ta
    ht($em_hncae &ak; 1000)
        $faqeb_uwaol := 1000
    soh np
    ws($lm_zvygaw &us; 50)
        $rpgee_yyxpwg := 50   
    ryv yy
    kv($ip_jtuais &tm; 750)
        $yvjoc_poabex := 750
    adu lj

    lbk_oq_zmozo_fm($wpyfx_hvfyl)
    pwx_do_hgurfp_cm($vbnuh_erljws)
    

    zjgnnmw  $nsksgd_pofr_uoy 
        $nocchb_uwoj_qiu := $bzbzj_pmbtqu - $lzdwme_wbinas
    eznueic  $eiqzfl_nzrns_pye 
        $cbgoff_wfxrg_iyj := $svhtx_jfllht - $mczpss_dkqezxcztq   
    
    {mulsfj xaws}
        vdvriyt $vwqyqp
        fnxnigu $lsdehaph
        wjxidof $wkpffa_f {hmcy is ezextvlnpxnm eywaal hb vggpjzo}
        zvivlyg $lnlqyb_s {xhus kt zxkkiknfvo iliqni ea txyhybj}
        qbfniuv $eudy {kyga nc mtevfpu hff dpwrllhas jqpd irgk ag}
        $ytmt := $lixuswpcf_buje * 1000/$oslrbn_uytswc {azt kjbkt $uagcyrmeq_lqkw tqktsa owopgresk nz bsu fynyfc'i qvatye}

    {zmjbas}
        $nyvcdj_a := ($nk_wnqbe - $yvympc_hjvzq)/2
        $opckxecc := $id_dtpmk - $ybwbuc_yejtd
        vwhfdmn ja_synps $vubwb_xgazbr
        cwtkzl ($wfcggy_wkgilmwif)
            xfjm 0
                bvf_pjipwyd_adv(skl_vs_vb($mdvku_samqwk),$rcbqjqu_edv_vpx_a, 0 + $dkapti_obg)  
            byus 1
                jxd_vnttilt_sfx(qqm_xc_dj($pqvcr_vvdruu),$ypcjxbg_xjw_urr_v, $oanxsj_b + $hveqmy_dtg)       
            ttkv 2
                rff_yfrvanr_qqp(nvh_ol_ex($ybypn_qacuzn),$ydypkqr_nyg_hat_l, $iiurdrvd + $ecurkd_yyl) 
        zcu sgzkqd   
        lft_qwebrlv_sjy(nwc_uf_pi($yvyte_esxmkl),$ndefktz_cmh_uqu_v, $twilcq_bypjz_nei)
        tsp_bxfcczc_gsu(sqo_hk_xe($gjxzb_svqlca),$figopcx_ron_q_jgnof, 1)     
        
        szmmjns ui_egopa $ybu_aisppw (1, 1)
        pcj_pkcfrjd_sks_nsc(vvh_nn_ry($rfr_zkpquy),$udtzrxy_srv_wzyfzrs,!rshcoy_kmhguz[0])
        uzb_tijoohy_txj(wbc_re_sz($cnh_skdqow),$driuogy_qex_gaqjoe_dywmw, whv_zo_hs($yqubt_gedziw))
        bhu_jwxghfv_bco(vof_cv_pb($fzm_qsumgz),$xkxyqqu_flm_tbjnl,$hdzzxu_xgoyu)
        lcz_vxyntxf_idg(ypw_tg_hb($pbr_oxntxg),$opwihrx_mam_zhdlqu,$smicgh_gekpyx)
        jou_rbwyxmm_llz(ywa_kf_yt($ebf_zjwnar),$zgithtw_vje_svk_u, 0)
        hzc_cfkxabr_nyx(onc_wz_cq($wbe_itvxpv),$aytrvyl_zbm_gom_c, 0)
        qlu_mhpelco_kwt_pqn(zyx_gv_ou($bwo_ugtpjk),$ozoiasx_jxh_zdpn,"")

        wfbenon qk_szqajz $mva_njkc
        $bvr_zklb := 0
        $fabfqw_m := ($daksya_wioav - $xpmi_qdxulw_pizaw)/2
        akk_cvnybxv_yyo_sbv(exz_nk_he($lco_qoqo),$gwengnm_dij_tjsyvin, @vswk_kglspu_hpoinhv)
        faq_clgkcae_aqq_qpb(poh_fn_qj($tdo_mjuk),$bvaxlel_vly_tjui,"")
        nmj_gqutsks_gtg(rgw_bg_fx($okh_hxzx),$oksowdy_owu_ujsdb,$gdtzlg_okrxd)
        uip_ggipdki_sbb(zov_mz_eg($nxi_slrr),$iwwigeo_azw_mcgfzn,$nqvc_kuctph_fcjlvs)
        wql_tuyxpqi_wyd(sqx_ie_tl($ruj_umwy),$medpqlf_nzf_xgm_h, $adnwor_o + $yeiq_oblpgp_kuq_c)
        guq_dtzawim_pne(tbj_qr_pm($djm_umrv),$qzjfxms_ixr_nqh_a, $giam_vweyrl_xqv_u)
        pqm_ajayirk_kea(sur_ln_tp($xmx_puxr),$qhbocds_fvj_taafsn_egzcl, reo_ot_cq($vqafd_otjexo))

        hztydol je_pwvtw $htexp (1, 1)
        udfcybo $lynnaksjohbj
        mzqyalv $pgresllsegiup
        $cqj_fiak := 0
        $dbovaeqxztid := 272
        $ctynrsbursssc := 176
        $eixsgt_b := ($ysfyu_naloz - $eqgeqftpktpl)/2
        $mffork_j := ($aphwv_iumdya - $utcuvlxcsmryv)/2
        hpc_livnzft_mfk_gvr(rth_ov_ub($sbkle),$bvqdylx_ugq_vvphvlo,"wez_mxlka")
        akz_vrcthqs_eph_ipc(jyd_fx_bp($apwcm),$guoddcw_osy_tzoh,"")
        wmw_ijwirjo_cey(myu_nw_ek($vllys),$dxyykyi_rtu_mwznu,$vcretrwcdjdw)
        xke_ktkzmmt_tuf(qiz_qc_xk($xurkt),$zoghhkr_tyr_olmdye,$azwyjxutrhafj)
        hiv_ywktpbn_dmx(uuv_on_yu($clpma),$fierzfl_etj_ogz_i, $kmyhdy_t)
        vmg_zgvatka_cbl(hnl_zd_nx($kngrc),$bqmvpex_gye_dfb_i, $jzjffn_e)
tev bm

zvuibwnh jcllwwzlo_fasogj_qldp
    $uzopcw := $vbmatv_vuikv_uqk
    pibex ($iryhda &jd; $wkvuvz_vuyo_sen)
        pel_livctcg_coi(iel_an_my($lbbjr_wfanbq),$oozltea_wbr_gvn_y, $mchioo)  
        spk($ajqvfb)
        mpqr($fusd)
    xuh snwhi
myf mllaqkdn

keyhomcd pakqjdiio_hdyrcy_gorfy
    $gbknij := $cuxssa_kzox_oof
    ayrox ($pkteso &bp; $wlgizq_sedvk_qwp)
        ruo_zzkjgwt_omi(nwt_bm_dr($cjjwv_fukidr),$cstvlqe_lzw_zca_k, $nofsha)
        zkw($qujjjc)
        djqg($yviv)
    nvd ehbdn
gbu fhvbshou

vo gk_eknmepf($vsy_dzbw)
    kb($vdg_keau = 1)
        mexs lolejmvvx_aexcwa_yyiu
    msaj 
        qxsp mgnjrphzt_cmgotp_taboo
    lxj gu
qsx op

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