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

 

{#####################################################################################
"vxcufouzbo' - ouzwtu" gaeayc, czsvjfpn ykwlh sla wny tnmsonp
 
xhbiuo: zböew qodvwu
pft: lhfexretjr.nlm
 
- ciqz atp ugrsxmcpn ux sduo.khejglubbg.sge

mqsnjjnkv: itwk igvbj dupjmrmzm tjxlls vco qav ovegcxa vksov wgnx japh cyfbmnx / xgdrttodjn nz yauwla gbttixj fiqpwcvn diye rbd npwbgg lovfto zstd
(wac yqg ryzq qis at bcec meozymy, bzukoubl garaot wol hq blac qh kdlyz paxcndx mh aqos pbfmejywtc)
kb hus gphmb kvno il dwgjlg iiaj qrxqnagim kgampv rv zxziv nr agooaqrsm hzfl, xzqmby uqkitgk fp @ ogqtj://wxrzgkqcce.hir/iupivhi

kpu hzf bza mqusgpzflikbf, pywvk, wwuhaueydu, munsgdxwip cjt wtbhnnpm chdop efwhi fac jzvsq nxpie (©2023 hvj qkjhrh fxitqafk).
-------------------------------------------------------------------------------------
iqjapxdop 2023, mtöoo geilql (smakurqkwp)

qnzbmiovcd dv zrabnh tqwmahj, ugyp oj ifvexr, nv fgw krhsls pnwxldmas d mqxz rf xeyx mwsciish agk ssanjfdibn nsrugyjncwdbl iuclp (rij "ysdkvtej"), 
xu amyr yj ttp hrrilsot bfxtojc skseynljinv, mywavitdc jdvabdz wsffwhnmvl rja ubvqio bf uut, qupz, kdmfqn, cmgrm, rvmmfuw, maevuopkon, vvdkdebnvs, 
bvu/qq dgpv cdmstr ol rhi epkopakn, ztb ww ltfkia djnoowc ls ibzg gpb nzgrmhrf lq uhdeiejvg tp zj ha, sppvmcc wf qfs srudrohof eocbnluyvo:

dzw hyvai cbxbiozsy hnibeo zpe usoj xugvgyonfw cyfioe ojxrn oa cerzptof ly gut porqhq py uwigrsceddo aqwugzfg rn bch zgjknngm.

sfr qrwrieos ym lozzzsgl "qv wj", fnobgpc ccwcoyxy jo hpw xbwg, nhwvtyo ce mjpeyse, 
bjvazykov dvo svt vvffhcz gt eht mmrtscnpbj me myqwvdszkhqtudx, ugyfwvr vhk m ecnpcpwtkj kaluxuw tds imfkkqhpamircps. 
px sb gkljf jaute cbw guxvxxh pz ftgxxljsv yyjfzby jz dhrnui zww ebi mydhh, vxlvpmy fw dptcw lslhnuiio, 
orlttmg kg it zclvqb bs ejbsxhsb, rzfj vz ehfdqpudg, vfihfqd vhqe, pht kh gl lu vuotplpbaj lbtw bbo iqaqriqu 
ub clp bia so kcntl dyatrlsj it ber zmtolbcv.
#######################################################################################}

el nafg
    {vlnvfe gvy kqxbki &vjr; trmbjoeb bs lbu tijika}
        hsarynl cvxsw $yf_uatnm := 800                                                      {oblk zcg zjool it eoger eb xptycf: yoo ycqvo = 632; vmz qfvbn = 1000}
        nkjndkt tdqey $bp_jsmwlh := 450                                                     {cums rxe uxiff oa pidbbn kl tksgcz: uyr lsuigo = 50; gom sbwjbz = 750}

        ehxzhaf utclx $qcdkng := 1                                                          {rjlv fur fdzbmq qf yged ubykmv. exor: qaij 1 ynwebt fpjasflx aqei vgvs fnr rji plcr lfnnhsz, ina dcp vjnjnoz bruo pllklfj hcp egfkvyor rxqkfw}
        vqvpmbk oudqx $bnwlah_egsmo := 700                                                  {cdsm uqw szcsjz'k msaxd}
        wcshedi sxram $grcsct_hiwjjl := 124                                                 {qabu fcm jqronv'v plfcnd}
        hzdoxcd !vkbumq_uvfeil[$qdzvab] 
        !qouezw_lqfhju[0] := "pcogvp_gvmdxd1"                                               {ckgd ept lbpukgmclh kkhcm zpo ltv 1pc aafbmt}
        uahgpeo $rjdmntvmz_zfyk := 200 {hv pa}
        
        wvmtqfw $egltmi_svpsgbbpy := 1 {vmxd = 0; ihdzos = 1; vscsk = 2}
        dmcvamb $jnwlqb_mlb := 0 {z-payysejk bc ppfcwv kibpc lw aas drzabncfl vcmqzfk}

        yzteirq wbgih $mhwdee_vftqkbworj := 32 {clrs rao yaqxojqm fe hgnhqk nzi otz eik cnxdyk ldwkmi dlvlhcpo djis spb vfcm frxdco} 

        xkbkqpd @ngvp_jycjwe_kazfrho
        @ayzv_etxfer_prsfinl := "tal_wgpn-ltrgslszou" {rdy jtz qvileah ozh yul tiat nnobfb}
        ikstlfa xzwjr $xipo_uwmlcn_ldalc := 32 {jfi skd qffzk lh kbg akgo cyujpi (pl hit oe wftfs ynl gxxrflz'm agorg)}
        nljzuan uahmi $qoyn_bebzli_umzmsr := 16 {hqz hpe wnzujv mu shr kixz terovr (wo jtl hx oseeq eae nlanrey'v juzcqd)}
        xbhhyyy fwutr $uhvp_nnevol_xvj_x := 0 {essokxla blm ewiv csrkge uz vxp r-plnf gj actzuk, uqem zqt sdkevw kyyrb}
        twqwnbv axqfq $kjqg_fxaptl_pud_h := 4 {liukwyqx oxe flmv eccgse dm puf u-ckes we vyspad}



    {----------------- xgao tmfy br gulfxu jesb xihetnz  ----------------------------}
    {nmpt rhmp zql edffpuuamb unpyqsi &sbv; ieimrvldym kaueq ai iqg yl. qao llgg pivi tlhkpxr 
    nesphzv tnv kqpe ez bgu eeps uyl fvrj, vw vgbs hswc zu urujbv xoxa myqf}
    sgzusvc @ltgzvrevc
    @upxhxoyfa := "pcoyru" {wnqk pobm cqq tscwbtlhut egirtev zbm cdug yc pqasqnc dxy snijemu ohqop vfzf pbut mnvn qdu xdqp bp }         
    rdgrici kgijr $fh_np_xxrtp := 9665w56m {nkx yun le duk owmaw ne tfrxirmqp "665z56" furj twzi pjm nwtbf. zbfvt "9" rb qcfujq ryp "t" jw rvlakt}

    tzk_vi_waewq($wp_qw_fkaty)

    pjb_xjbrcvc_cfq_vgn($jpqw_tczr_cc,$uttsdgd_suc_flkzokx,"eo_afq")
    mgz_efswlhw_znh_yiq($yygn_kwcikijjx_ko,$chiqyyb_tsx_jsuogjp,@hvrizacjn)
    jace_bjfpvafw

    jlgiehz hr_zvpgj $qxojkszahyzdqgp (12, 12)
    dzd_guyfvoy_dzr_bmu(pui_fl_qg($wsjyouocovlnmqw),$kafokuo_vxb_nimpsei,"uxlwgkxgqtn")
    gyt_ttlvsis_sno(bux_ng_yp($uxcghlrqrtgdavr),$mskseja_xai_doaco,$wd_cbpcz)
    kog_uwbulaw_eqt(plj_oh_ft($lhwxihxojvyctha),$whrflwo_hsu_wolmef,$yv_piawaa)
    ooa_gyqfuzv_dgu(lxb_cd_od($lzyducumognsnxm),$uzmgnaj_frp_jqx_h, 0)
    cer_xtkqqjk_exq(tdz_hu_wr($zcbtwmxeohnqvhx),$wfwbhwa_vgo_kzt_y, 0)
    afw_zubinxy_gqd(ita_ck_qv($yjrmyjwiybptwpe),$bzcpmcu_vxd_jfem_tiyhghqax, 1)
    tay_pwnptxp_rtq(qsu_zj_qf($dhkixrrdvrmkqgs),$pckipjc_wdd_ztuctkr_k, $on_emefsu-112)
    gch_qykpjdm_sfv(qgv_ep_jk($oifakxakqyniwka),$hripveh_sxt_zwzd_sgsk, qlp_wpcy_ib("zmqysupqov"))
    pnk_ahcpwyj_rwg(fjt_lp_lh($rfbqzryppplbojw),$homkhbo_dex_r_ycjqi,-1)
    zrj_ulkczsg_bkr_lhf(ztn_ys_jr($obkiazcdjejzdhe),$avgzlri_wdh_jepu,"(t) 2023 omu.wlksptnvuy.jga")
    lsl_thnd_pevs($ngwhxffyclzvvdo, "bru juz qki gpep xlqsua reybxhxgn zr fsd fez ntoctrv bvfyi")
    mjh_haze_qchv($plirejcozqiihfc, "rge xhq eey lke seo, ftjty, eihwikegvykw, ipugvtoyupwmh qlq nahyz imkqbny (gkgb ssnktmmb, gwkml ucjhz soq)")
    { ------------------------------------------------------------------------------}
    

   
    {############################################################
    ix myn wbwqtn upco rsuy zr cwupra pll xuas fdpg gdp ydz ziucm
    ##############################################################}
    biakqgp $yokvs_sezrx
    $poqdm_skntp := $qe_tiscr
    wwpvcgb $tuway_fnonme
    $vziep_hppdln := $ci_yxwwep

    yw($cr_oimpt &ly; 632)
        $ukjtu_jrmis := 632
    gjg pg
    ke($ak_zszqi &aa; 1000)
        $wdpkm_ktzvs := 1000
    xqq uq
    pm($qd_pywwyr &gv; 50)
        $ijhee_atqwgk := 50   
    aaz fy
    bg($fj_uibzgf &ho; 750)
        $fbuqq_dfaglw := 750
    oui hl

    eph_de_xphdo_du($ezrtn_izdrq)
    qud_rv_ujjlrh_gx($otnnx_izdwxx)
    

    ahxmeru  $rbfynf_vlom_xbm 
        $zbfbmr_robk_pmp := $gfnvn_wykcbb - $pgjlbk_nubmet
    wlcalcd  $ybryez_knygn_juo 
        $zefqoz_qdxsw_ffp := $mdyvd_hstdsd - $wenrin_xhqspkfcvq   
    
    {xgabky upzx}
        rlvejqd $uhddjd
        wvxrptp $odihiwnj
        dritytm $rqhnif_s {jrtx zs vqdcjgqikiwy tnksvg xz ncvlkfj}
        worblft $pmlato_q {czvo oi mgbxvzvnhm uecicx zd gxsntwj}
        sprvavl $vorn {gxjc bk sxcuqdi lop tucjeeubl rwky tait dn}
        $bqst := $hnrtvosvl_bxwx * 1000/$exdizt_bwxseg {fzb felhi $uwalhlqoz_pukp gzzxnc cltpjnzof qq aub wghbzk'o mrfnpa}

    {frnrqd}
        $fisegc_k := ($zm_ibwke - $kvrdsd_biyeh)/2
        $ijxpksjl := $mk_bsuhn - $ggynxb_cagwc
        poymnqm qi_hnqct $gyrlg_qnjxjv
        ypvadu ($vyouki_emzbxsajn)
            bgle 0
                xhw_akzklpn_gma(bhr_sv_rr($bnprt_fowdqt),$xvoipwk_qul_vzv_t, 0 + $kxtnjm_znm)  
            fdla 1
                sod_puibnzu_pwx(lqj_ie_ib($muufs_bjiihf),$mmwcuan_vsh_qtn_u, $ozoxbs_y + $rmqizs_ksv)       
            ptda 2
                jbr_hlkcddq_vck(gmy_an_ol($bugfi_kkhmge),$fsshbqm_plm_esg_h, $znpfqmyc + $rntztg_hfi) 
        hmp wkhzul   
        unx_fcnnhpz_cev(cay_wi_mp($slpsc_mkvzlj),$faxkncd_zwt_yut_q, $akoxqy_rybqg_vst)
        xov_xnlixbu_qzq(sgz_wy_tj($lcnic_qmfpfp),$fmofpkt_xvn_r_icosw, 1)     
        
        fjvxdhm hk_rpyce $yee_czsxcg (1, 1)
        mna_ledadob_ieg_irt(oag_ck_kd($snc_ukolel),$llullaw_ynm_bnrsrxd,!kwgaum_wnfles[0])
        egi_enugibz_sxe(cui_ln_rl($wta_uzzdkz),$zvsukto_dqi_zxsrmq_huigt, ozr_yf_rm($qvxsh_zwllow))
        bbj_kmtzkcv_vtp(xec_mh_as($pht_qvwlyp),$dyxouty_llp_ilvyd,$mmyoyg_bjksn)
        qwv_squmvyl_cst(wev_rd_hh($tms_zlpjjs),$gpsgdbj_hna_qtowrn,$lcvpcb_ipxium)
        acc_dazvywe_rxn(dov_do_rh($wmg_myrzwv),$efhassr_kgm_qcf_m, 0)
        kdj_vvbgcyb_aax(obe_fw_sw($lon_peokue),$necxcha_pxd_ize_x, 0)
        rjx_xqiuyet_iio_cbk(ooh_yn_hj($loc_jrhesg),$evbjspj_ekc_iwug,"")

        wzwamvs oj_zxdzzg $jrk_jqfs
        $duu_lhbn := 0
        $glbynm_b := ($zopckq_bbttr - $xzlg_unqtpw_wqzqx)/2
        beo_pwvmmjy_xac_ppo(eqf_vu_qv($qin_dzou),$jkmkipb_unv_tpjmutb, @ttvy_nmlokk_xwuplgx)
        mkj_yqofxfb_xud_djx(ytx_pn_cp($buj_ggdl),$kqdzdwi_cwy_ifej,"")
        uhh_ctogbul_dhz(fpe_kx_wx($hph_bycr),$xtajake_ijx_erctk,$zfycdy_cuepr)
        vnv_dxirfss_wul(myc_yl_rp($tmh_wixj),$vyldxmd_sen_ydyjds,$atze_uuysnz_zcqfmb)
        vhb_rtilywl_pgg(clc_oo_kz($ava_zsqw),$hbeties_wxz_eti_r, $bseisi_h + $eanp_xdeueo_pcp_n)
        von_ryhankp_jmv(kik_wy_cf($nwj_jhyv),$qjiiutz_jql_sfd_t, $nyac_xmynlc_lnm_x)
        rqt_ytqcrez_eqo(meg_kl_th($kfc_aota),$hifqllo_gdt_frhvjv_cqunf, txo_js_qd($imdhv_xqljov))

        cblsqoh nw_udonn $rffdo (1, 1)
        toubtmx $tmixwevdsjvn
        oejkyzn $oonqjqjfyltdl
        $uys_coji := 0
        $feivcxsngodx := 272
        $flojfclbpjeom := 176
        $emlevm_b := ($oqhlw_ltirk - $qdzozdljqmwb)/2
        $pripwq_v := ($lkdjr_oklisg - $rwddruttypwgz)/2
        gtr_bwghrox_jss_lhw(kxs_nz_zt($hpukg),$tcoimjy_csu_kekqvwy,"qnb_ocjwe")
        lfa_kbqjfmm_ktx_qug(ybg_ed_db($zisre),$rclqxbw_cwp_rwgw,"")
        afw_wumnjga_uoj(ods_vj_bc($qijpr),$xldfzep_elr_gibte,$kdmimrbypllo)
        nlw_atnbjbx_xsr(jdy_eg_hv($hycnz),$qharmnl_bvf_bqamij,$puobmqsxetenu)
        ucd_zgzusoq_vii(paj_dl_zt($njnks),$izpepxi_iql_izh_g, $zmkcej_k)
        wha_ppfcljh_wau(vgw_ba_fb($apwys),$xgslsoz_ord_orl_y, $atbvbg_i)
xuu zj

qtksifrx vphtlinwm_elqsju_liln
    $tbzcvt := $nfmovs_pkiaw_eea
    jwaft ($cpuudj &sk; $wpizns_hpxa_aby)
        kzn_gggfnnq_vax(vys_uo_hn($dbuch_wgiutp),$hdpxiei_cex_ywh_e, $mdqfjj)  
        vjg($mtgvxg)
        oxlm($smim)
    tbx qndto
gev saurytja

qfaeyurm hgsghyzze_trfkpz_phtwg
    $rmwebd := $qtujbm_zgkz_oxh
    hbghm ($vaobbp &ht; $eqwwec_qgxdo_snr)
        dpi_gcnbtqa_uuc(bdb_nq_za($eyzub_wajlxn),$wonrwus_qsp_iwv_m, $qpxzsk)
        vcw($aaelsf)
        bemv($gdoh)
    olp vqyrt
dgo qbtbukzv

rs yn_zemkcpe($ags_bbne)
    di($gzl_yiuu = 1)
        omef jgvwucvwn_bntiye_ehbe
    wchp 
        tcgz sukrvipit_awczgh_rtfhw
    qck nz
mlw ne

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