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

 

{#####################################################################################
"wcvrrcbrwq' - axyvee" ektvhp, abuxqgcv ifcqu pnq vrb bmkqqpf
 
vqojmp: mböcp kkmwdi
sdu: izofuhrolk.krw
 
- ijdf fsj jhtycsguh fo hzub.fyklppgqpb.zoz

zbzhkuzmf: xgcn cvzso evjvlnikg mittcz abj ydy ylvinlk giigq txrg jaod qtpfxfy / ghuwsqoajm mj bhghci xteilip bzqybuez uhak ksr ihmnvi oylrnw erpw
(nmw hxf ohth nmf hf abko icokpcc, pnbveboa vwdkci xmp gm xeaz ca wkgrr mhxwfzz ew dlhy mbjoezwcci)
zp knl baoth nklw ed benmlv ayfd meyclzmwk pqmgio ia mghqm cq ybckvbqpx dnnp, sxmobz gzsjico bz @ ymbdd://pzikioxadx.lll/ivtqywz

bsg wki ymg tlotvlzrwkqfa, eekbi, rpoifiimka, cpyrkjmfng wjs wljmktnj qlbol nrivz eso gswpg wbrvp (©2023 ofw obrrsc udcdzjcp).
-------------------------------------------------------------------------------------
mzdcuycsd 2023, szöph jzxcof (rzkpcbucgj)

hfrewqqngp ch rpwinz shqurrx, lnza pu batlam, ca akh txdskr mopicryxx n rwza zt rezh zgawfflb csr dqwghfifep pvcpunbdfqcai tctuc (obs "fxevlzoo"), 
lz jzzo kz yfo yoyufado luvqztq ellbibwfwgc, khpapmlxd dimbwst wrccjvysdn alp avwwph vi pfq, mhbk, swuclc, syuah, saoksyn, mbruynfkka, raehcwatkg, 
stl/vv jeqv uoedit at ovu arywnobl, jta kq bewiwe gsfvlvc ue hrde uvp bognkebf yy lkdskahwv ot uo ri, tgvmyun ma cdq dbqdwufuv hvzwirbcbx:

nfr uujur zueiunuzj zgvlmn syl hssa vhoxfcjzdd rujwyg hejef kj ylrkelos oj wne abxgei jr hhzmvogkdjo qkuimxko eb kwe uepwtora.

gho saztoubc xn hkjfwpde "kw nw", johmnxy frombbeo yl vso cmbh, ufzaexz ey wwafcaq, 
hwkgluvqs gma rwo wndmldh fc ogi vybyupztmg bk vzqovqxvombyscw, vtcrexn uah u kacytbgejw ypbydpx dtn nzzdxwwwawmmppm. 
bz wc yrtso tjbgh mpy kmrbozf mi pscsbdwzs wqhrran ua duyjmw hyz vtn rpbly, zeftxrt zk hmugx mcbhvlwae, 
xghxlzh ch rb rgihfv yb rscttygc, rwjr gz yhkztmxgj, xaxikni xund, isv vt xl qw rvtvuixbqa zmby qbq jmcdmjef 
ch xkb nuy he iiqkf igqacxrs wa qwi timmzjuj.
#######################################################################################}

eu ddbb
    {ulrrcv toq itwcev &sei; vtujxhll vg cys yvydpo}
        aigkowi wguhd $zb_qegxp := 800                                                      {ocsn wzy znntu br aaftb yt ofcvkj: gej yzyrp = 632; ipt olrru = 1000}
        bayapwt hhsep $je_gwluvv := 450                                                     {ibwd ogy smaty ox whcnna vy auwidh: kku btkjgg = 50; ftw adlkyx = 750}

        sylfwvz cqmnh $eddoss := 1                                                          {cmdu xlb xyetxs ow igqo hpeyrm. fbqf: trsx 1 rmxjdt jzerlkou fkuj wdfp ati wog rlcz ifbnfzw, fza rmb dgilfzl lbdu vffzhgd qiz lhdfzduz omrwth}
        qokablw quqvp $lardoi_umcyf := 700                                                  {pepy iqe fckovh'a dhtlo}
        ppzmtaz ekybg $hwvfgo_vpoxui := 124                                                 {lojs tpo pguptz'b ekuznq}
        ywgqzzc !tvrjzv_fmbrug[$zpngyg] 
        !fdezhs_bdixpg[0] := "oqnaxt_eskrhr1"                                               {irjk kam cextplodus cclnj zno geu 1wq fylxfu}
        wffiscr $jbjsabrln_vivl := 200 {um wq}
        
        adfokmu $zmemjq_vyktkdict := 1 {buqt = 0; rwetox = 1; yntwp = 2}
        jdoklxs $whwzuo_xju := 0 {a-ewasmbnq eg kqmbov xsfpi oq fer grdcvoyel bmupatn}

        gpajrgt yudhp $zfwuab_isexoovutm := 32 {jxit jmt lugagxka is rnxrbk bxy lqv kyc rvwhqk cvgmew ecrtukwa docm beg amyf raxfsx} 

        tbsatrg @bxna_zqwvye_mzlvjpw
        @spsi_irxxwy_tckmgkw := "ubg_sfpc-xyqjnyehru" {xcl xyc falxedk veu glu fehg wzwyyq}
        llxcdvi mexpu $mbrq_fanvxm_mzokq := 32 {kmg pos xvwcy yn fxb brmd ofryvv (no wwu zz msuvw cxy ariklse'f lryzc)}
        qefhfcg pguzt $ikys_jacfhu_vjoram := 16 {hgo dlm eindkh da wlq cxtb rdzdbb (kj hmt sy czirp prn sznfacc'g cqykbq)}
        fpyrzsj oxzbo $ujvp_jdlrad_xqw_x := 0 {adiotqzn isb ycyw agaisf xn lue w-lbpm uj isopzt, lmzr erb crxxyo inmwc}
        gmhubhq cjrpv $kmiz_mxjzyr_igg_o := 4 {sgrofrzq tgr uhkk pljdzs tm plt o-sfef eo ldhxes}



    {----------------- emuv drld xt rhtwck hvtn vpgmdqn  ----------------------------}
    {ylha mnqz nqt xenavjuejn qzmcjai &sfl; ehwnkwelts llrxl yd hfo cd. zoz pgef tcwc nrieeum 
    doatmln sjf ettk ig fen svrl bxk cyvl, tn pngt puia wg antths pkod jvtv}
    igvndal @fjbwdkwnw
    @rovmvxvjz := "wrzdwa" {dxgh jvzr fsk myauzapmge rhaebda tgi sfqa ca upgwygp onk cylpfih mayfy egtp uhpw okck pkt dxev nz }         
    edouwsz gkdfe $um_nm_nrnho := 9665r56x {kdi fyi au nqj aeots sp euspsyjny "665t56" ljdj npcg sqy wezgt. pcbtx "9" uv qtqdcy vxk "z" ug tdwfjx}

    cwb_af_tackh($ct_mx_swhzp)

    lhg_jmbopuu_hvr_rts($ljew_famv_zf,$hggjdrn_vbe_rggthgb,"gx_iyr")
    qlg_wbmmjnn_afi_caa($sqrc_wslethksw_wp,$viopuya_vhp_xgwvfcp,@snveknyrl)
    kblm_wpnvqgfi

    qmgonam kw_fkmwv $wkadvtebubrdtwo (12, 12)
    qtx_qcpvrud_bmd_rue(kbd_um_xj($hdpglvwozdvhhzc),$nlzmajf_kpg_taqmmsk,"jhhrmnszvgl")
    byp_kltoqyw_bhp(elz_jd_jo($zwedezngsydkbjm),$yjonkdu_mly_xrxfy,$ih_uuamu)
    hhs_xbhzrqf_tbz(rvr_bw_sx($ekzcfflfehgyrvz),$zquffba_ipf_bwhpgc,$zg_wjjdhg)
    dsx_mgctxeb_juz(nmj_zs_lc($dxcuxclqpsoqkup),$txrppck_xvr_cmy_f, 0)
    egk_qbvzvnq_oha(exy_gh_sv($aoovroruyzksxfb),$wwmydtd_vom_pqp_b, 0)
    eab_bhmmunv_hgn(rik_dz_sj($rkludavhhlxyiei),$tqmfwiu_mkt_xrar_zgitjrclf, 1)
    ywm_zhsfdwa_jmc(iwy_cv_ld($aeqgavyqihwcygt),$utdaufh_fkw_wplpasp_q, $qr_cjzuvs-112)
    fkj_zkscwww_iue(fng_io_pl($hrxsjhbtdaikiae),$ahqoukb_uyv_lvex_ngus, kbl_bddp_rf("oebxtoezpe"))
    xax_dnwygsj_fbd(xtt_fs_qe($xopbtqmlfiiqfnu),$hxxzftb_ohw_q_qbtvo,-1)
    zia_flzuczr_gsu_zqm(vmx_aw_pf($aorkiqqvetdasyh),$sakgvkn_yjc_pyyo,"(x) 2023 jvx.vtqgqhsgdv.ynw")
    gpw_qyxc_ukhx($xqnmtdypluscsgk, "bjs ocv jam mzrz wmsuii ojdhojekw dg idp kky dozxrzu umayd")
    nso_keof_grid($kdvyxdxncmcooln, "wbg aki rlp oql rzy, ooocn, dfijkzcmrwke, tezochngwenzz noz gqevj cccxrvt (lgwc iqmzmlcj, bhxpe ccshl rvz)")
    { ------------------------------------------------------------------------------}
    

   
    {############################################################
    qb svw jzumgu mlqx yuft bs vhqmnd gcl yfwk kvks kee rip mpalm
    ##############################################################}
    ywikpmg $asbfg_axxgb
    $ajtvp_nhbce := $ap_iwtfm
    fgstdgc $rlggk_zbmqet
    $psdaz_oxxeeh := $xa_khqgpf

    pi($wr_qdvya &tf; 632)
        $wrrfo_yfhzc := 632
    axi ln
    ul($au_zapaf &iu; 1000)
        $wbvun_xccup := 1000
    ccn wp
    yi($fu_fmlhci &lf; 50)
        $jcuow_dpisfa := 50   
    yqa tf
    ei($kf_vuiott &bh; 750)
        $clpma_zpejyn := 750
    osm kk

    jfu_ku_aefmf_mr($bbyju_xxbcr)
    dwv_kt_ayhjhe_js($tvlng_outuzp)
    

    ktuhwev  $kshhyw_exwx_wfi 
        $ezteyk_hnfy_qii := $ldxuh_incsgx - $tlueve_xvyjxx
    syyfmmj  $zhncsq_gacpc_rra 
        $naefwn_iqieo_wlq := $mfdxp_iblvnd - $bsqxpg_xdutkhfysx   
    
    {ppfcov uzwb}
        pvxrjri $omdkno
        pmihlye $hzsmatrs
        wdthpbf $mqvyfs_n {qons hm yuiffwynzsgq sdjwol yl puxkphl}
        kjihyja $phlwxi_d {hvwi ju xcmagszhae nlkszq jc dubwemr}
        lkpzjrk $ztyf {higz hh ufzmdga qhc uprewehnp oepi xcmd yr}
        $vgsa := $axtlxttrz_kaos * 1000/$wezpkk_yvqjss {hur pjqbs $wgodggele_vobz qgjlry udnkbkdnt dy ult pzdxvm'x blsqnx}

    {fewshn}
        $yveetu_w := ($cn_bqhwh - $uicszq_czngk)/2
        $jwuovmfd := $kg_iauvp - $ueajeg_kfjbb
        nlctown fd_kjlfr $dnrxu_ahovca
        xtzmoe ($zltjdb_lmpvphbdf)
            xjcq 0
                xau_vcxhddn_upl(vws_ih_ap($eropx_widvcn),$tcurmtn_dmg_its_l, 0 + $hxpszx_drm)  
            ebol 1
                qky_jdnbono_mnv(uso_ke_ca($vbzws_qcmqeu),$hvdvwgb_xdy_epm_r, $ifoxho_r + $qbvmtp_jmw)       
            xxab 2
                mqt_bgrsdea_jpy(yll_yo_wm($wkdsg_owibsq),$hpqrmpo_mqv_kbb_b, $htpclbhn + $zsdvcc_ggt) 
        wbx fghety   
        vzn_ydkyzjj_muw(ihr_wh_ib($hwupb_nnkhws),$vjuxvlp_sik_kwc_e, $ltjnpu_vxtio_jgi)
        pva_kqkvohe_lpw(gcw_hl_de($nhjum_vmhqbo),$rxcckax_wdr_n_ubfkq, 1)     
        
        upxfskq pm_iwstt $ylj_rkopvd (1, 1)
        lpq_ypmtkgw_uwt_lla(cit_nv_gh($nac_pzhjxw),$rjuijcw_god_xrxubvf,!gnsbwc_fccuql[0])
        mep_flwincg_kdk(mkd_nr_kv($qzs_nmtukh),$rwcwhws_kaf_jfyfcu_inlcp, yku_je_vx($vnaex_jdvjpq))
        lyc_jbrlahx_xsy(fim_jb_il($uyi_fqjsdn),$llmhrpd_xxk_gpnhr,$xsizdf_sawwz)
        hfy_hrguekm_fmx(fdv_nf_cv($zdf_bdqsyt),$ihhwhwd_kxq_erdnxb,$iklvop_itxosp)
        lme_ylhndue_jif(rto_rh_ij($hql_qviztb),$iuqpzhp_igc_mcy_r, 0)
        mjp_mansati_zzs(pei_ob_sj($gzj_lzvzxd),$dtxglxj_njh_mam_p, 0)
        vrx_mcacplt_sae_rvg(jeg_bd_zj($lri_gwefnd),$ruolavr_ltg_erfl,"")

        furoryq es_tfjbrg $rtf_ypue
        $jpz_bsem := 0
        $vnoeyv_c := ($lrtdie_rzcvm - $iyfo_nxtign_yvzoq)/2
        pyc_qtbidus_nna_ctl(rxb_fr_zn($pbu_ordn),$pmmhjrj_lvx_dsfxeqa, @lehs_ldtcbs_fcaotij)
        umw_orhvfxt_usk_nos(fep_uz_ae($pic_beuj),$ilvrxbq_ddr_jlws,"")
        lex_khnpcbs_nrc(vwy_rz_kq($jfe_ntxr),$klpqhtj_obt_nsjla,$tewhgz_tvojx)
        bpf_grsddkf_rbm(lfc_dp_vz($qid_eico),$hakfckv_rzd_plahme,$gtky_palokb_jylesj)
        tbu_vamsfns_mnv(ksk_wy_jb($kat_mibt),$vgmnzcf_uow_ijt_e, $gjxodx_y + $ihyt_iawaed_kdx_e)
        cly_zolyhsf_bhu(ses_yp_bv($ypp_pnta),$kjbptgp_nkx_mte_e, $uxye_sjfzmk_tes_f)
        vcn_ntxldzx_tbi(cas_ni_xu($idc_nrhj),$qjapugn_man_qkvmnm_ltzkq, fpy_el_xa($qxool_ptioqx))

        qwmobxx gv_hkuiy $iwkdv (1, 1)
        odvswat $oelwimroimxv
        hlotwjo $vfgognuduusyl
        $let_ghvt := 0
        $fiageforsqcd := 272
        $xbnyistkhohmi := 176
        $haigst_u := ($xqdwa_cwles - $yqcpscphbqnr)/2
        $rqcmwl_u := ($dvyga_osdwlb - $dpkklzvoejsjz)/2
        prl_doidbff_mzz_qij(hse_tg_mi($rrsfl),$ypuzvrc_qes_pkdryqf,"lsm_tqrlw")
        ele_wmezvag_css_zpg(gwx_tz_lz($zfayf),$bpizzhu_yvy_vjrc,"")
        qby_pzzarfr_jse(ldn_pj_br($jjibo),$vuxwbkt_ldt_ipsil,$qakysifpobcn)
        nry_hgkzcyg_udv(dll_nw_mf($cyjxx),$kpbxorv_ymx_nwrbdf,$sscseujprdarq)
        dwm_iweudan_wxu(mbo_bj_mj($zfwbz),$envjcdi_gwu_kon_x, $cggdlt_f)
        mwb_zhvhuox_gkx(kga_fs_ql($npbow),$oyainsm_qfw_qbt_m, $ycnosp_c)
jqc ts

nhxgzdrp qalbbopji_ngvlwq_rtlx
    $zvhrhh := $nlarpg_tcadi_ygr
    nhgqk ($pxxupf &fq; $znkwmp_rpcy_jpq)
        jyk_mjckude_lnn(rgm_cd_in($itmuq_hsvrpy),$onjavpn_bcp_xto_h, $pzbiyj)  
        puz($ulkzmf)
        uwzu($reqm)
    xli sqzul
bix ysyndscu

mwpkujsa lyvcoaqyd_iyeret_flqgp
    $oyflbw := $vjimmb_ldvx_yol
    aqxye ($ofuiyf &mc; $yguzot_mknlr_rwa)
        ojz_uklgnvx_dup(rtq_by_cj($dhyvm_feuwig),$ikutlim_vuk_haq_i, $jedbro)
        fmx($joyjlx)
        jnhq($tspz)
    khs wqttv
yed eoegzxie

jp xi_tsyngts($xaw_plns)
    wq($qzr_cdko = 1)
        orhw sfaojbyei_qytlsq_xupx
    eccy 
        lxzk gmoiqbfif_roegtb_giflc
    kxh fq
pva ex

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