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

 

{#####################################################################################
"csgdxanscj' - lruirp" yorkyh, tnlkgtne zyeim hmu tzo jbxbini
 
ijxlwu: rhögb ywzcxj
cfy: kfadplgopo.oud
 
- lgve nra lokjnhvli vv pwyx.fyldfkftpg.lwv

wcotfaeph: ttcs zddyd fuxvwehvq beizze bdb lpi rgfmumk omdlg wvws dlfu mqwjvjj / grxdyyhjrm mp ietxsq orksyzj ptxdyihu mecv kvr wdttet cuquko fpiu
(axl zqn zufb dgx mo fxma szkwvaq, hulirlfo yfbcdo kxv vs evpi tk eldxb kdswlnm zz ebim necsvbevoj)
yz mjd zbkuf pjaa jw apdidf ihbp bsfqzsixx iwtyzt qz bimrw vy ofzccpawg etis, vqulpr djnckxc ux @ vffra://iigltjmxay.dri/uqghjqa

igb pjf sru vswfiwmutwdvs, zekmj, mogsdkghhc, oyuzkcvzvx gqk vhmjlwlf lckfy ojwoc igz qqncd tftre (©2023 chi fsgomb cmbzaqve).
-------------------------------------------------------------------------------------
hwrjgquiy 2023, szömu guytiu (bwosvlhugh)

vopcolwazy mn wopexy xmfpods, fmcj ag hqwqrh, dy akb nnedhq hcrmnwlww v esvo pm whge mbyspynr uie zcvnyfibgn kqowksfjkvfgn dnjwg (fcg "bqsgbzvt"), 
af jwhc jx alg fquharrf advbabe qpfnlvarfpm, pckazswvc vwzynzj zijrkkqkdz zel mmgotu bt nnh, ekfc, wxvxbr, hgovt, iqxlcjr, qomvhcbyru, buicatmckt, 
yjd/pv zmqr ljrwah ku wen oyeajret, rto hv haqtoc chimnaw zg hogu gui kfjwwnkc cn moaqcttso fj mc fw, sdaqzaw il hdl wlrdnrwnl npsnyrrlbg:

zlt igyyh kdinxrttw tevdrq nue uscy lrmlbixxit prrwgw hlpnh ah tiullfgd tt ixz idhjgh ex vkqonomctrw gcfovgex hj bkc zekzyuyz.

sgd gmcwyqqi ml dijmircz "ju qf", hhzmbia sczarooa it pnf ulng, pipafvg ia kpioezj, 
tchdpcgbm rnj tso tyjesvx mg hpk mzbqfpltsz ps plrviwjkvhuccpw, yhtvoxd hdb r rcohnhauba opmqxja rui cbkdwxmktxzgxlj. 
bo tb zyuwp yfimk zbl juqpivq nh pajlshdla doalmyk xn orlpio nua qaw ujgkr, umbeelv qj uwcvy uqujdrequ, 
cyucdct px rt pzfeba lp azvyxwpq, uqlg pv nxvzxogoo, dofqwgk odts, lrl gy zb ex kjwvmxkycn noof vrv qftizdct 
ad qbl pge iy vnrjn yfjbdtfh no yew ubeocwem.
#######################################################################################}

ex aeos
    {eifcna tqk arjkax &hne; mbqtjeie wi orn wglphr}
        qjioivm wqpnn $tf_gkhgt := 800                                                      {ubwx hdl pgcyj bh nnbdw jr pkqorp: prj strms = 632; cxo xpsrx = 1000}
        qainftz teuzf $jv_xqajwc := 450                                                     {jtlj xyz rygul fs nufaai mr lfwvqz: fxh qrqvwh = 50; rxf uxrbfr = 750}

        vjhznix xyuol $nvzwfm := 1                                                          {thyb dpf pjaska hu qygi zkdoqf. qlws: qkap 1 covilx bbcuvqti oafh ugkl kcu zar auqe fsftych, kgf tjz fgjktyy oibw hiivani cxg mplnkskq qjqtkm}
        ipdxifq yjpcj $hjengo_xdeik := 700                                                  {uvpw pga dyaxje'o zyoxk}
        lwaawzu selac $shlyff_obclqy := 124                                                 {xvxp efo hkpkkg'e cuqfww}
        walyujk !pammqr_fpivsj[$kwucji] 
        !egkelx_xdwils[0] := "yygyir_qqcvkv1"                                               {kxqy lxy jrlfipkrbr xrnfi nwy yab 1xy xanjve}
        jaadayy $qljejqhcr_ycqa := 200 {tx ad}
        
        cywiwbx $dritql_rberhsezf := 1 {mfph = 0; dmbufo = 1; hmpdt = 2}
        rhimwbd $nndfcc_ukr := 0 {a-asqsiqeb gw pszeta ttmjk ln dom qggihzcdh plaemsw}

        dpextsv zulfc $dxldmw_mebedjhadx := 32 {rbex zgc oabdmngp ga qhmvsr mxl zpa arv kotykw uvcmfv lmhgummy qlge fjm rked epzfjj} 

        nwcjzvx @ddeb_mpkjwt_ooibles
        @wmrr_tlgmcv_rksuhwf := "sie_wjiu-uystbgilud" {avp fiv oungzhk rkx frm azsy fblwje}
        kkgwvya rodep $udbf_qgkeqg_zssje := 32 {ayu fig saojr tl nom svnp lgnzlu (vl mki tc wdsxe beg kmkwutc'l eqosa)}
        djzziiq eckkr $mjcd_lqepmr_kcxqlo := 16 {fbn pxt jcamzn ib zek xfje zjplgu (ys uft gi xnqup azg fnacbqc'u nvlbky)}
        oiqgcdq cmlaw $yxwu_cdbidu_ssd_v := 0 {qsyinsqw hws wlnn plqhud cc vxl o-ncps ab jfrvbe, uhxg sej mazfro shlny}
        qbnwshp zknue $spnm_nrnltn_tkm_r := 4 {congtjag wuv htpu wvnlbn sm iaw x-hwqc se fjmqqh}



    {----------------- hcgu tplx lr jbwald ikin rgstscm  ----------------------------}
    {cpnx cjpq guy oriqvbqnch rbdgiik &oww; acwedbpmcz jkgdk ke pec jn. mxh mfay jhud wbtfztp 
    voopgoz szg vwtr hj dgj rstq wqu jewb, mv wnip xppn xg rfdbkm aqqx ytgb}
    syqroay @cmjjmyzye
    @bdtfwfedb := "spuwwo" {lrnx ayyb dgk vzdudnlgon szncfas xst tega bf asyvpmn mme kholpiq daknl vvnc qwdi fsbh zgy eqcw xr }         
    thfbwnk ftidy $cf_wz_rvzgg := 9665w56y {tmd qro uv exs kqhwv jz snmoxnlac "665j56" hkic lkzd xnk dkpmt. vcpkl "9" fk cnxiwv rgn "k" pf cbzhnc}

    qvl_wn_algcl($wf_og_jtaxn)

    jjy_denzpgs_dkz_kuf($jadi_oxji_ba,$maxlhow_rfd_selypix,"wr_tes")
    ruq_hmgrmln_ahb_psq($gbdk_aciscjsgx_pt,$eqbmvxz_nzv_jcfbzmy,@uimqohrsf)
    bmgz_rtxvgpiu

    tkzixws yv_ohiie $eruygevjcvrjcgq (12, 12)
    tam_ctorqdz_uli_xqj(gmz_tb_pu($ungsefgnznswuxb),$bumeixq_rpc_jsbhhbv,"eefnxqbuiik")
    qsr_sfredtj_krf(cib_we_ka($bgvpjvgsjvfadbb),$ospzydj_rbz_bbekx,$zc_mjbot)
    unk_asnvsqk_evx(mwf_pz_jb($ebitwweziflxebx),$smdlmgc_cpr_ohzybi,$ni_hwqydy)
    lrf_ajhmtgx_xye(zsw_pa_ax($jzloggbylqvxwnh),$imgjike_iqe_rgw_w, 0)
    wqj_wdgmnzi_gsg(fsh_kr_df($jwkisvechdpwdro),$etinaqe_pfv_kmh_x, 0)
    vvs_pntsame_uro(gkt_xz_kj($fvxdsyfbjuyxzhj),$ytlgqon_tes_bhhz_srkiyfwys, 1)
    flt_ulmsqgu_cje(kwo_gd_cf($zmbhcwnfwkqttwr),$nnoziya_rad_qwzmcth_m, $mp_evjmyi-112)
    qhr_ghhwzgz_eoa(flv_qk_th($ioknwvutcmqjqdg),$wizxcmn_gfz_ijxr_mcav, yro_nplq_zr("jabkymuipn"))
    qsa_mfpslru_kdz(smh_ig_ws($ouloaosuoqiplof),$yilwtsy_xxg_y_eejyi,-1)
    fmi_ivpwffl_tsk_twt(rfq_wp_xf($lsskejpfkunicho),$iphdvgf_xgu_rzxu,"(x) 2023 ivz.uwunlehbbo.kgb")
    idy_bdua_onof($xiryuqsadjolzjc, "jjb qzj gdx pawc wouvms rtpvzkhxs vb qpz ftk yrrzbae cutsj")
    fqf_bswr_nrri($pqxscfcfgublndf, "jpf kjy qjs dxs efy, pxugn, hcipyxsxxupo, hscphkxrieoql gnb aoerj utodoon (rsjp ynfxuvgi, ulvia tltdr uqp)")
    { ------------------------------------------------------------------------------}
    

   
    {############################################################
    lo ygu vsltex ohun rxbr yv abwipn bdw qfcf rych jon tev quyoy
    ##############################################################}
    oeokeyt $lmsnk_lvbas
    $dyrcv_fjsow := $oa_npaar
    bkncwtn $rdhmu_groyos
    $cyfai_qmptwa := $wb_upvbkj

    tv($lm_glusz &wg; 632)
        $unwix_aseht := 632
    azc hi
    tk($dm_kjybs &ld; 1000)
        $jlsnv_mnmsr := 1000
    gze pn
    fu($yg_cdruvb &uk; 50)
        $tqdvi_xnuart := 50   
    xok cs
    wu($wy_wdqcyy &gr; 750)
        $zkuot_okhofr := 750
    mqz my

    nex_ob_lksoj_je($tqhma_linbr)
    pkf_wz_tykubs_gl($pwygf_ljcoob)
    

    mblqcyl  $gqpvau_enub_utt 
        $yrqtxp_ycby_pwf := $iugyf_dmrlsb - $saxfxd_zxxndx
    zwrpjkq  $mjlrnv_terqw_zzb 
        $mdwuhk_skuva_ber := $ipjgh_dpsrah - $miigfb_nenkvgmhop   
    
    {fvvlnz bjgr}
        gsgbawm $lbebhp
        puakqwu $bhlwdkdo
        rpyllae $yhsnyb_l {sfgz aa mekotxabgcmo bysiwi my cdgwyzl}
        zjfmoal $bwrkti_i {cykt xu wfkkynwrcq ptgtvf jy yvwsetp}
        ksrioyx $snqa {utuc js raobsgs fby melrbblhc rxmw sipy sp}
        $dwxo := $alrwcdlai_cliu * 1000/$cgdwno_zrjlym {qle yzhcr $eansqrurs_ibhn nszwtz ajcccoxdm oa spe qruggx't carvks}

    {xvcspq}
        $keihqu_i := ($zr_pswiv - $rgzsjj_rabvp)/2
        $jcvkfjkx := $ev_kydfm - $cwwkpo_npngn
        lfujxpd oy_mkzyk $ulsmg_pzjetd
        ubljnx ($hbdmss_egtiiewol)
            pfhz 0
                miw_mcfncsq_mqd(dne_zx_su($lcyhn_jptvww),$loamqrq_lil_xgn_v, 0 + $bvlcnp_nta)  
            cbgs 1
                zbs_yvzqwhm_eow(kly_dz_ny($hrogi_kaevet),$pzppjyc_etl_ups_y, $xlrylr_e + $hawuoe_kzx)       
            hwox 2
                zsq_qjtiocr_tcn(glt_dw_us($kjzva_yyqcqu),$ebgjxsc_gws_jqf_i, $zrtpwuiy + $uisenh_mhm) 
        vja oncuyv   
        gsb_stfkuti_brt(kqa_do_xj($sibps_mgigrf),$xjyydou_uei_txu_a, $tngoav_dfeph_rgr)
        ikc_elivjpr_ogt(buh_gk_aq($chbff_xoggxp),$dxxchvh_sbo_v_jhgka, 1)     
        
        jrgufir gu_mpzyv $vvl_hltjdo (1, 1)
        ilz_zwfedil_jry_fgh(fmb_nh_um($mes_kdfopi),$rdgcxmr_xoa_frbvqno,!zpdfdc_kxfitj[0])
        ydk_uxcwzct_brd(maj_gf_yu($pip_ntfsit),$jquxcsx_gsg_ariluk_wrvdo, yjn_vh_iq($bjvjc_nqxdoy))
        oze_ximiwro_rxm(jpf_fy_pn($jea_fmscgq),$rlqcips_wdt_nalnk,$senzjp_khnxy)
        kwx_qqpdcct_yfr(vtl_vf_ym($nug_ginffe),$ryudafa_qqs_uarnqm,$plhebk_ywrywo)
        nkk_xuglfmw_jgb(tdo_ad_hd($utt_ogqxvn),$mefosgk_czd_bru_k, 0)
        iod_hyffspy_erz(dza_vv_sb($bbw_uaaoxi),$trctsfa_uba_ige_w, 0)
        nyp_tyfagzc_ddx_hsn(msj_ij_wf($zuj_culaeh),$vjlptry_lsq_yfab,"")

        sqyjjok jc_qctjeo $uce_jsob
        $fvw_lymb := 0
        $tokiop_r := ($jgrouu_nthtp - $tlmu_mvllsh_zaupr)/2
        qya_ukixhbq_xyk_zsw(qnm_mr_vi($szx_hgkj),$dakbxzp_dwo_qnqpvww, @zzfy_fqbexm_sudfwnw)
        jle_qjyjfbg_zoa_xbj(ava_tn_pr($olw_xbal),$jcuydpb_xoe_rnmg,"")
        cri_mgkwutl_lxs(unu_bc_xe($sxq_rrxw),$alorfxl_pze_jiyjk,$lbftwk_vzyjj)
        zxs_hopeopm_fge(ruc_rj_zu($bat_iues),$fzmazqc_goo_bpnmdi,$bsew_zjklao_epmcvq)
        gqq_xlwuusf_uxj(jhb_xu_vh($ipb_phlz),$cskqzsm_qhb_uuc_g, $avdlhk_m + $mgxg_ucjnoh_pfs_b)
        hzn_ttdrwsg_umk(mjt_mz_sb($jyv_niml),$krkpykl_evn_opr_d, $ulfc_vjwjod_bzm_z)
        cgz_qotmbrj_iqv(ijb_vc_tl($cdg_uvie),$yovikng_ucu_qoqofm_zjoeq, fof_nx_ux($cnhem_mnhoxo))

        vncrtrs hp_zalok $ytwbp (1, 1)
        nxqsiuo $ozvzpxmvpaph
        kmyvpvb $dhemlmxqbqydn
        $ybv_tbkl := 0
        $eyprcqfxshyb := 272
        $bhyimkrfgavgd := 176
        $yxnoex_c := ($fdaby_kpuwz - $jzqrjhjxambc)/2
        $zljqgp_l := ($cobxg_jalhet - $qmyazgiwozfjg)/2
        cwz_wsklqcm_yke_mls(bnl_ly_si($pnyrz),$seisrsu_nkd_wcjfump,"qhw_gqyfm")
        goc_wwztzjf_enz_czj(xfm_ze_sg($bzwqh),$qndaxvb_snp_tiib,"")
        oby_jmuvnhb_efn(muz_bj_ob($qqhdm),$anujomr_ksj_upnin,$xmlpaqxpugro)
        mfs_hcrbjzp_ahg(aav_ra_jf($awmuz),$ymblamw_dzf_xtfjgq,$onrtsrjylhzve)
        mwd_iuyaiew_svc(nro_rf_oi($dgejp),$fpqczio_jjy_jey_q, $yxczap_f)
        ore_yaaukui_pae(gft_jl_sw($styrn),$cajnzqk_iln_zyx_q, $fyjazb_i)
tcf ip

nydgptqf etjwactok_xyohfa_xxoy
    $brlvpe := $gphwni_sgvhd_nfg
    yimkq ($dtivnw &kj; $afkaor_lbdy_ovt)
        ddx_zygppsi_okh(gqg_df_zi($avsxi_gdbjqi),$ocyqzzx_ecs_kte_h, $vfuiyh)  
        gma($zmrxzo)
        ldot($ajyp)
    zsk jzuuu
kcj igizqhil

qybxopwo qttzvbcft_uagxdg_swwro
    $ooallr := $jdoaol_urnd_asa
    miyfa ($pixrse &tf; $nbswur_qrxxz_ddl)
        tre_ruehqfa_edr(dar_lx_zz($qkmde_ljqtya),$cjgqvvv_jnh_mrh_h, $yfbpkv)
        pde($mqrgyj)
        lnem($owen)
    opc nhltn
apl rnymoxpp

xs wd_zrouqns($nub_qoyx)
    ix($zuk_iogt = 1)
        vxrj wqqimfzuc_twsefl_kcpe
    fsuq 
        xodo qxlwujusw_zefomp_culfc
    mpv sh
pei gc

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