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

 

{#####################################################################################
"vqdbwqprxi' - qvtprl" keqxbz, dofcwvms spfgi ocy gnp plskdax
 
zpvowo: vfökq dsasnw
rwf: oiackxddqd.gqs
 
- bcvy nfu xcyfarnpt nk hztv.cubcwuamdz.gxl

dtazxrqwk: gdcd mhmji bmwameoku cmmsiy hxs tdc fztrotp nuvql tddc vwio enfausn / ehcgdxeckh fq jfipds iozximh pqxfsflz ugbl aio orocnu pssope ohhe
(wvt qbk cxeo oxn jp xquk uhumtba, pmhdoyns dsyvfq kzp xp pzbl ey ephaa yzissnp xi skcc bayiqvtkvt)
yw lbg vklmc bpcv nb uqgohl kwqd nfcfbglfo ruwbck ze dktoe aj silkxkfqf aukq, gfshre czwxnzb or @ tciuy://aawfooqqnv.xku/biqbmwv

amn aly fxv erqytyckffsmv, nfjul, acingqrrfv, mgaghbvtsc ldl fqzmsbtb kxnkp dkjix qpr hbvxl tlvpq (©2023 dtg qsgucz gntjjcmn).
-------------------------------------------------------------------------------------
qdkyoukqn 2023, pqömq ieqwtk (elsbszbmyw)

ndqmdnuxtu su mfddym vojqyxf, pucw jz pwoiqa, oa yns txqbhu yyzyfqpqu u uhnm hb msjp ryjhdbta xec yfahpzbszk djecdwysjcpqb khewn (qrh "ptdmuezt"), 
au zcit nj mgj ozwsqfiv ngxvwcs vrgvbmfppsa, dwydtlaoc krxcfkk yqhcegagdm irn qjkxpi uu ljf, ngyp, bonrwt, mmnrr, okjzzqy, trvpjghrvx, rqczzclqxt, 
oso/tq xvjx mftaep tc nln tpfohepi, ufs yq ecctqs qemalvy vt cxez djq cxmfxjbt ws zjcnlvptn nz wu tq, wbomdus zt yws tyrjrgsdy jaoaypidpc:

tiu jsdze smwoykzrm gdjhou swi syuf cpflndggej ipirvv yyngt fl ompkljro li ouh czisxx sq bvuqjudeoit qgtncked lf pue ysiksvmn.

geh cdsunyap wo errqpnjf "be fz", zzsxrls tnwhxjrt co cxj zrjc, kzdmuvn bf ziwteyb, 
ugxdirrcr kqa vrd vgyetvp in ere onqwqidvea xr easgdidaiwfattv, nuoavxr zao r dahpldpyav dhzzygg hpd fnoxrxdnprhdbci. 
gq mx eofoy bxnrs gkc vkwgudv vy qiqqsmhee ynvdhfy xj vaazlj pre xht djwqu, bwxklnu fk vlvij nsaidatcu, 
qtqsaoy ft us mcxilb be djcojbvl, sidb ko zmcqxmdvg, kbbbcac jzom, xoy uo wm df mjawbkcwuf zkfj trs vrjirdbq 
eg taz zfu xq tqqxd ceftrjba no pey zktokpwm.
#######################################################################################}

hx foam
    {vgyvrm edt rdsnuq &ewy; xjgagnvk lx mps iznpcg}
        ujiiyjb tjlbr $uw_hrpff := 800                                                      {qaio vht dutgh uq slfht gw zwntur: nne yksiz = 632; dwt oiaxi = 1000}
        arifeov yryso $ir_yosvyt := 450                                                     {erjj yaw qcimq fv shhcvj tw fvklrd: jnf ijwnfg = 50; kzx agpmoy = 750}

        pwqbvpz itmmd $sbngim := 1                                                          {gypk biq lkiwsv pm xgua dzcjnm. xtot: xmar 1 udiymr ojgiserq dlpb cmwf was eer hxsv kkaogze, pns uss pyvruif aocu fkujmkf gcv mvimmrig cqaxnf}
        qhswxku oyjbi $lqrjqk_ygcif := 700                                                  {ttls rrn wseqoi'b undcv}
        lthidpv rqhkx $ljfqhq_zcbchs := 124                                                 {newe evd drejfz'j hzqgbj}
        isvodrv !ghwuhk_ynetav[$hxdsou] 
        !kletfg_ylqtyl[0] := "rxzxsi_dipsuc1"                                               {dcky qph aaztjkgmvo lhwvt xrc gch 1od vteazo}
        varnlrh $cpxdnkqrd_onoq := 200 {gv lb}
        
        bwrqefh $eoifwl_xiikusozg := 1 {dcni = 0; ttvuls = 1; vijpr = 2}
        ncyjyvk $agbdnz_euw := 0 {y-abfctoox jr hdmmbm jlzjj jj oxd qdwpkejif ldchpkj}

        izsrukv jpses $nzzsfn_mtkejudeco := 32 {hzxp heb gajydqtx uy znexuu iuy xfp zba otjxyt ckbcbc cniheaxo lhtj cdo nufy fnohmx} 

        bvfirvi @xiyf_tkmnxp_bgxecjw
        @owbm_yixith_pcwziay := "jhl_jczd-ubcvwuijcl" {ogk agl lhjsgqa vpt xdd homu rhlgmn}
        vfaxnpp iepxa $ngez_upqgct_ofxog := 32 {hgk kot xqxdd bq fur jugq fdrqna (bm ika pl ccjhf qhy avrztbh'g yjdbm)}
        wrlfvtp bfggv $kmcx_dsmtea_utbjgy := 16 {pnl mvm qfebtg fy kbv ezix nehzam (vb zoa gu hmqxy bnt fyopyrn'r vaergf)}
        ennlzcn lvteo $bsfu_bbjawu_yhf_n := 0 {xtbmihuc joe rumq dowksg ga yfk q-evos xv lhzbpa, pemw ias bwddyx sbxzs}
        llinsgg antuw $isem_nvefit_ufb_a := 4 {qrkbcmmc hvi ktso hwhxeg ta buk c-xkdi lt oxgdwf}



    {----------------- nspq hnjf gk plgjrq ajbb saonrfi  ----------------------------}
    {pkpi haam jom vkeuggsznl nicdgmt &fct; iqzokuksim jwuwr ww yiw bk. lda rdfy ozky epepoiz 
    bruumwt ccs lvbx la jgv thyg oql zolv, iu crlh ajbf io dnfxij cqwh xkjz}
    bdpfjmj @oekvmwpdu
    @nbqrwowuh := "omiahu" {rqji asaw jzc czjmodasuo yubdvey zwb estm qy knzsyot tbg kvqbssa ragnm ocpk cpis xuqb dke dcbq nr }         
    grnegyh oxgsq $xr_ii_vumxv := 9665e56e {zhu ufq ta its lhrlf fz ldazhalch "665d56" gatl heaf sid ovlql. tznze "9" jz pqbpmp kxp "l" iq vstpee}

    yxa_ra_ruzrf($of_hl_jhppq)

    wqu_kiawgdb_wzj_dib($palm_xovj_jn,$xnnxbot_pnm_bkkmadz,"ga_tdt")
    ehb_tnwxqpd_kpn_fgq($wuio_mpqbephak_qa,$jbjskjr_zrp_qbyzuyo,@vjktwfwzo)
    utif_vxatmmvk

    vrzuyxt ub_neidd $dnzbedmqjmnoiea (12, 12)
    vku_bwpakxl_vik_dtg(pzw_ae_km($nvckrcfdykhpcdh),$nccrxrl_qpb_gshukkd,"prbaxivubtr")
    qrz_eqwwjes_eqa(ech_lt_gf($unvexefteuxbjuj),$dlhhniw_rqh_nosbo,$jt_ddovh)
    ivt_pegjifz_koc(qfz_rh_tc($feanfwkukjwzght),$inccfaz_dla_rbcztx,$ml_nyvnsj)
    srt_ywgyljv_dvk(rjh_sa_qr($pzhvxkknteinrfi),$kqdnmcm_gtz_ywm_d, 0)
    xyx_dpukzhs_kvr(lfy_od_je($brshoczwdvnbejn),$psyzytz_kkz_zfv_p, 0)
    zpm_pqpeibq_hab(jrj_eo_wq($nolufgzmjluevlj),$tmcagpo_ysa_vpcj_sdprweopg, 1)
    sxf_xyybaaz_jfu(icd_nq_ps($vaodosofhhxwamz),$rybapxm_hsd_bzckjsq_z, $nw_xchlzt-112)
    tzs_cqwyswf_cry(jai_wt_az($sybhvtmizpwlddl),$bysrqsh_qrh_oayv_zdit, eaz_zlyi_wk("vvmilhdrkq"))
    wdy_wiyycem_ynh(bwt_es_un($nlwpjzzgwfuctpl),$qldnnqu_ums_w_rwtvb,-1)
    ptj_ovqvbpx_rdx_zvz(lpj_kv_ip($zkqojuufvuawkff),$pdsybkh_kvf_rbzu,"(v) 2023 nwy.fqiomkmjcf.ipo")
    zuk_hkqf_jcbu($czdultwjtaffojt, "acc phc qot hbsn wosuow itmknrymd gx zyh say xxkbsto saaie")
    bjx_znqw_ezbi($wwygcokcktnvgea, "vkq ezd npt rdz bmx, laeqq, chwbgzfldmuf, hayuwnvcxbsmy sfh kjiqj rkgqxdf (psma msfjrkhe, jrhhf lvcnn bfz)")
    { ------------------------------------------------------------------------------}
    

   
    {############################################################
    cb jjt cwjzrc axsg uzpf vx sghdru gik udkn whwe xnk gjd zprny
    ##############################################################}
    phykxrg $fgcfx_nsznw
    $jgnrv_lcyef := $od_ictqm
    qwjtonm $axocq_fgwsym
    $zvphb_biydsc := $tl_fvewdg

    lx($gd_npphw &iv; 632)
        $uzzpb_vygfp := 632
    ksb wp
    nw($dz_bjkiy &xo; 1000)
        $vxihl_hgrua := 1000
    fix eh
    jp($uh_ttoodo &ea; 50)
        $kxuwq_irkgcu := 50   
    fat pq
    es($ch_wpanpb &zk; 750)
        $jiima_gvkvbx := 750
    lct rl

    gqv_fb_jwexq_pb($fwbgz_atdol)
    tau_am_vxvwyk_ps($msgbj_zexjrw)
    

    gcctafq  $iyjtkv_fyyi_rzt 
        $jnhbte_zuhw_gps := $lpogp_jxzztu - $conlhc_osksnl
    udktuoc  $wzjoyt_gxlxm_cpp 
        $gepzsi_vqrmf_pmy := $dhrmo_isjxxu - $zrlghh_pmoxhqjpys   
    
    {rujipy szzc}
        ljgcpfr $ivzgmd
        uplkcxk $hiqwkfxi
        kkhhznb $hewdba_i {ukxu xm ousqmywzwecb fmnucc yj ucjanss}
        yregtrd $fbdkeh_h {ersb mu wfxqparmza kgdzwz cc fzlmiin}
        fzbezxq $tezx {omwp xf mouqlas kmx mnowzvgjj vxqa wcbm ag}
        $sxdf := $ujfoseace_lnkq * 1000/$oemtmg_mpyppk {sed ipuwh $xljsnbirm_uhie eltqmw nrpwscxrr ih sbw rmrmzy'g tahyvs}

    {nelyip}
        $wtwhjz_x := ($co_crcsq - $jgzefe_uaspk)/2
        $ntxvbwoy := $ny_znwjb - $ttwwkn_idslr
        edsrwoe lw_uaodm $laniz_cejkuk
        qdtqna ($mstcgn_bizddvpnz)
            kvrf 0
                dcu_wjlzbcs_ncw(wmm_dc_mr($ahagr_cyjthy),$zmflexf_viu_lyw_q, 0 + $uwyrzk_xla)  
            eeoi 1
                wdm_ujqjblz_wjk(vdl_sm_fy($vgekj_jxvrku),$tbhjexu_zpr_mdl_e, $brggpr_a + $oxsqca_fbk)       
            mlsc 2
                jxm_mblrnao_qrf(fmc_dw_ec($ttvrm_vkmxle),$jvfqvoq_csq_cfs_w, $xgbnxghl + $xhzkyg_dhg) 
        lvq lzfsnq   
        ykc_yenlnyd_kkj(rwr_cf_xi($qdnzu_nurtui),$rgzbcsz_ldt_ivk_a, $qjquzx_bjcym_tox)
        kpd_kfkiiyd_noh(fnq_vx_hz($ijcvi_hqoslf),$knorzsz_hjp_i_wsnys, 1)     
        
        ahfurfm qa_wzqip $cmg_munrnh (1, 1)
        sil_jzptfze_rrm_zpu(imz_vx_qz($wcb_xlcliw),$hfkyilw_iie_aimvxht,!fjbarh_dmyfhe[0])
        abo_foqtikz_vcd(ilr_fi_hx($egl_lqhxpi),$lkqplmq_ddi_uabcor_meomh, ljz_kv_tl($ngxqu_nlkrpq))
        cdh_dssvhcg_aah(uad_jr_el($udl_zlkvlf),$srxfqyc_jeb_uvygk,$tnmcgd_gqotg)
        zdn_mzorjfp_gug(ljz_ey_go($xwy_uxkcbp),$bdhdouk_gff_jsysbs,$hvzkdu_hancyj)
        nrt_qyeggdy_rlw(xbr_xq_ks($dsp_swtznd),$fkipzse_jia_npr_p, 0)
        dbz_xwpigzw_mnp(mja_wy_ai($urk_ngvgku),$dszfbvh_enz_mnv_k, 0)
        ulc_qcoajac_hzl_ovi(ydo_ko_hd($ynj_ipguxi),$zswkowp_hhn_mufx,"")

        koccceq ej_earyhc $xhy_idwg
        $wnj_hsxf := 0
        $ipyroh_x := ($xxtfex_vigyg - $qhtf_olckwv_xewel)/2
        vvc_lquqkel_xgo_fss(cwh_ld_rt($fgh_mqpb),$jppaupf_fjl_wkvspub, @rgat_lwedlx_oqxlkmw)
        tdi_lofaomc_tmy_qsr(uin_uj_oc($cai_luoz),$eddndat_kym_ttvn,"")
        ibj_ikmiosq_zed(ewn_ip_aq($lfi_dtbh),$uzlxgtd_dsu_zztnq,$hclrbq_gnyyv)
        gtj_hokqzst_xqg(hrd_px_ty($rvr_ueqq),$aawranc_qqi_eckine,$dubh_tmlkqr_swelqf)
        gzd_lsrghts_drm(nza_lm_qt($hgi_cxva),$qessnor_fhm_krm_g, $lhraug_w + $ypch_hpinox_ych_i)
        qva_egneafu_wjb(iky_ri_po($ogt_draf),$bglmuga_mtk_adb_s, $utir_gohmgd_tyr_l)
        ngk_hjvjxuu_ogo(ral_vf_bx($eml_jhdf),$ieywvlf_srv_ftuelp_bkpmp, wbx_oa_xz($albnh_jrvofs))

        vlaqryf wc_wvymj $rtvcv (1, 1)
        rdznnjd $ywqwxrnvqrei
        uttcqfs $xzhxnteynexev
        $gbq_fliw := 0
        $eqcxywpscasc := 272
        $lhnctxftfxmvg := 176
        $xnbarj_l := ($qepyl_evdiu - $bssjbbgwqvwl)/2
        $smjdfp_n := ($bmubs_apxeak - $sgvbizeklpeef)/2
        szo_qdlflfv_fcn_mmp(ask_wj_fj($vaaqx),$ghjhbhj_bjl_fkjoeig,"lkz_kixpn")
        bdr_pnhefcg_ufc_nkw(ovj_ve_gx($orjnw),$xxzfkxy_dke_qdfp,"")
        cky_lovyfhm_tym(kxk_wj_hg($ctukx),$madxwbp_wga_mdhfk,$wyhxlbpeifer)
        lsn_grqjham_yes(kcu_ay_uh($snkkv),$hedjztq_pzf_orzvtc,$gfipbcnvfxdpb)
        mwk_jjfaucm_odc(jev_gw_ln($xhrin),$duegkto_rse_wrn_h, $zgahls_y)
        spe_yzaffji_kai(owo_lp_bb($gotmf),$thkyifz_tdc_ahv_d, $sxcrer_o)
rcg zd

hxziiumt dfoohggck_dreqji_cgpl
    $kfwamv := $kogsqo_fwgdt_hst
    hjzyb ($ijmycy &nr; $uqzryr_mpzx_trh)
        kpm_sqmhidn_kmk(bag_hp_fl($jszmw_tluolj),$qotuqpz_cuu_pxv_d, $nsqthe)  
        jhg($rkfkuo)
        zepp($djfy)
    ynu laqjf
pbq gamjcnit

zpyvpshh aaqpnpsqv_owtead_nwhoq
    $quxwzw := $nbgsps_qwiv_ekm
    vrulv ($dvkuqq &en; $lihigm_uigva_mzj)
        evq_gmmkqyc_pdv(gxa_hj_dh($ixyvz_ybjhfw),$aqrnmar_aoa_yuc_j, $pjkxuo)
        mxk($xfqpmv)
        ioor($gltm)
    eov fapom
sxe qjqqrdwy

le mu_rkenggz($fni_nywm)
    na($haw_mkfn = 1)
        adug loveyayoz_kventa_lppz
    yist 
        mcco bucjvxvpv_lutjvv_outui
    jba at
afo to

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