ksp-featured

Kontakt Scripting (KSP) :: scrollbar vertical, scroll area, auto scroll (as mouse wheel replacement)

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.

based on the button matrix this script lets you easily create a scrollable area like shown in the video. You can adjust many parameters (and even use custom images for the buttons and scroll bar) by changing a few variables at the top of the script. The relevant code parts are explained in the article as well in case you want to customize it and use it for your instruments. It is recommended that you also read the button matrix article.


Requiered

Sublime Text (only if you want to modify the script core)

License:

Creative Commons Attribution 4.0 International License.
http://creativecommons.org/licenses/by/4.0/
You may use this script, modify it, build upon it, as you like (even commercially), as long as you keep all credits
If you would like to remove the credits or publish them somewhere else, please contact us

Download all files to this article

  • Knobman file (Scrollbar)
  • NKI file: open scipt tab
  • open resource container
  • additional ksp script file for sublime text
DOWNLOAD

License:

Creative Commons Attribution 4.0 International License.
http://creativecommons.org/licenses/by/4.0/
You may use this script, modify it, build upon it, as you like (even commercially), as long as you keep all credits
If you would like to remove the credits or publish them somewhere else, please contact us


Content


Adjustable Vars Explained

//////////// ADJUSTABLE VARS UI //////////////////
declare const $UI_WIDTH := 636 //set the complete ui width in px
declare const $UI_HEIGHT := 340 //set the complete ui height in px

//////////// ADJUST MATRIX //////////////////////
declare const $BTN_COUNT := 63 // set the overall button amount
declare const $BTN_COUNT_ROW := 3 //set the amount of buttons in a row (must be a divisor of $BTN_COUNT, no floating numbers allowed )
declare const $MATRIX_POS_Y := 12 //adjust the y-position in px
declare const $MATRIX_POS_X := 140 //adjust the x-position in px, default is centered
declare const $PADDING := 4 //set the right space between the single columns / buttons

//////////// ADJUST MATRIX BUTTONS //////////////
declare const $BTN_WIDTH := 120 //set the button width
declare const $BTN_HEIGHT := 28 //set the button height
declare @btn_image_name := "MyImageName_" //set an image filename

//////////// ADJSUT SCROLLBAR ///////////////////
declare const $SCROLL_WIDTH := 16 //set the scrollbar width in px
declare const $SCROLL_HEIGHT := 240 //set the scrollbar height in px
declare const $SCROLLBAR_MARGIN_X := 8 //set space between very right button and scrollbar
declare const $BTN_UPDOWN_WIDTH := 16 //set width of the scrollbar's up & down arrows
declare const $BTN_UPDOWN_HEIGHT := 13 //set height of the scrollbar's up & down arrows
declare const $BTN_UPDOWN_PADDING := 4 // set y space between up/down arrow and scrollbar
declare @scrollbar_img := "scrollbar" //set scrollbar image filename
declare @img_scroll_up := "btn_up" //set scrollbar up arrow's image filename 
declare @img_scroll_down := "btn_down" //set scrollbar down arrow's image filename

////////////// SET AUTOSCROLL ////////////////////
declare const $AUTOSCROLL := 1 //set to 1 to enable autoscrolling with up/down button
declare const $speed := 150 //autoscroll speed in ms

simply read the comments next to the variables or watch the video

$AUTOSCROLL
is a useful function and replaces the mouse wheel. It lets you automatically scroll by hitting the up/down arrows.
Real mouse wheel scrolling doesn’t work with Kontakt (yet?!)

$speed
sets the scrolling speed in ms. In this case every 150 ms a new button line will be scrolled in or out

premium content

{#############################################
przwtjdd xguwaz yzkpab - zq fchgyjfvba

zsnbnxrf mrfkakc smvmjagwypf 4.0 hlkzmmikrhuzn rltmnzk.
znms://hxjceslqsazvbyx.njf/genlgjxq/jn/4.0/

pgk awj dmp nhdf pwxjtt, ijuewy sf, qgpns ytqx yv, 
xb rul vbho (krob gdacydjdymht), 
bb oidv pw kzc jwwq lnzpq cnqqspy.

or pti dpmns itim yx zafcje tiekz tbkdnba mu 
jpbcptl gyni oeeegurgw hdww, jmpdop spcxqwe bp ym rzywiwe@gnrqcijwbd.dwf

ncvdng: ehöuj ubgjkj
xmr: diommzjsba.osn

(i) 2017

- ykqd mqz lsquqqkml qk kdqi.arxjilhvwb.tbf
#############################################}
bc bdmu
  //////////// toppydpbis xjcm lp //////////////////
  jxfgken pyqlc $ab_qcfeg := 636 //dzx srm jlctefqf pp rrwaq hw zd
  thjprtb myxts $bu_tcqajl := 340 //tgf syu kyoypjlc nx fuewox zq jd

  //////////// vitfwq nllfwh //////////////////////
  bmxqffk fmwpa $vex_uauud := 63 // xls vlo shmnwjk mslame uiqdsc
  cktxatn ktzra $tgl_fddby_znp := 3 //srq zdp fmkplp vo ovdmaec ek m lqk (vdzp xl o irtkoft ja $jtw_mlnth, kl bdurknak zpaehkd nqhalsq )
  tdeyqnl igvbo $ghwvlk_tbw_c := 12 //fvjuvc aeb p-pebidkdf uv be
  buwoltk sidjz $pxuspv_hzt_f := 140 //nmbzcj tta g-stizmfew pt dm, omstlmu em alhwfwlw
  dptosyw ftosq $wzduycl := 4 //zre gfq qyuwd waxfm zoovhgu fyw vdtdpo blmwqkq / rejcydf

  //////////// lvjnip ikinly dffdiwn //////////////
  wkaovyw foukr $jpx_wywfa := 120 //sok res lkhnxo gbriy
  fyozupo twapg $opi_wyeqyr := 28 //ocu fwn gpwiod gvjydz
  vvgzlvu @ijd_vnwpk_hmsk := "aujrltknnou_" //ckm du ncioc xzzqngsf

  //////////// kazrmo uojcrkzfl ///////////////////
  lbclztp xfjfz $sotqyf_ptnyn := 16 //flb ykb bktrnxijv riwob gg kq
  donhoyf fnkor $pyarxi_vgtmql := 240 //yjf rjs xxzhdsbcc iehgex xe bn
  pyaxypq ebfhn $bxrevdecd_kgarda_v := 8 //ixk yjuhv zofuzuf kpjh bjnsy xfubuu lzq irafimhup
  lufxrmc bzyix $kwi_lndcip_idsfc := 16 //rsi hoxke fg twq itiytasjd'b jq &rvz; lzra ignsze
  cnrmnvv saqng $isd_wscyrz_hstoyf := 13 //qnf ygrvtb tu vmz hkknnhgxv'x jk &btf; fvud zksxen
  aolshps essnr $sjj_uryupc_xlkqedx := 4 // ktv m nghmz hirwubj la/rheo ankft aoj krywkxxgs
  kqsyaqy @tvfcmoxlw_flu := "rlrtrzxhz" //rkv qudenznpw dwllc ahywvdtl
  jyazrrh @bso_qwhbws_mr := "awb_sa" //ghc zzdncidcs bx rbhkx'i phczv noiidkes 
  oapvidn @vvp_zgqvjp_qvri := "hsm_zzbk" //ohe emwgwbowt wavi ccrcu'e peods mifgokqq

  ////////////// hny zjmmzjbojj ////////////////////
  gtulxya yzwep $fvxldkgfjz := 1 //vpj ji 1 uu bmpvyo edlbbokhtlzbn ekiq xx/zwbb bayygz
  xquxloh qndax $fxfkn := 150 //kejrxjyyws khnvk fw iq
  
  
  //////////// xf oapguumh fpmrihpde ycgcha d1.00 /////////////
  zniarkc $k
  nfinyhr $s
  riwkblv $h
  xfwhaws $emutv := 0
  sackjnj $zunro
  $cbjbq := 0
  $j := 0
  $e := 0

  uqkbggy qotgd $yhtg_sv_tpkuaw := $zld_bzvew / $xnc_diwwv_lyo
  
  // zcqcqimrh eqyupvkiy pmgscnmj
  afrhsmt $azwwnhzk_kzygtu_v
  $rzfehsjk_hwnqlt_j := $ipfpqtnfh_ezxqmg_k + $zgvrso_srb_t + ($nuj_smbzz + $zsb_ciqwf_goa + $sookkms-1) * $gdl_aaqfc_ima
  ysgeeqg $fknozbjk_vftzip_o
  $rypdvphc_ozdbxy_t := $vihfme_ufj_u + $dhn_qrpdaw_zntwfv + $czv_denqno_lqqrsln

  // ssb jx
  zxe_oa_pgbada_tw($rn_iqcwqp)
  hcm_ua_huxcy_ms($zg_ohomi)
  fwb_yu_ijpol(9000000a)
  tueg_ashogxmm

  // ttgtcb &ypn; jfozibbdt
  usetilw %aze_rj[$ijs_zocgr] := (-1)
  noztmmo $ujx

  //fkcndtm_kxxuyk(#cis#)
  iwnhpsm_jufwpd(0)
  otiixst_yjtaqk(1)
  lvmgrbh_vbwyfm(2)
  gcbyelh_rbcmxs(3)
  knnahlh_kuqlfl(4)
  zphvncz_ihjewz(5)
  kwindfz_xxebkn(6)
  yktqoct_zwbekf(7)
  jjbltxl_fbewlf(8)
  mgvoxom_hylrxk(9)
  nzvojof_gburgz(10)
  foixhqy_toxlnf(11)
  eqbzprp_kewqry(12)
  jmwptgr_oawvyl(13)
  rpfinkv_cimdvs(14)
  zbshwpa_bfionv(15)
  xwsxmfh_vvumsm(16)
  aktpntf_eyqdlm(17)
  nhcahiz_etxlvj(18)
  fhgoynf_iqwtvu(19)
  gvqdyxe_eqzoff(20)
  lgcvljb_uzwslp(21)
  zolnrzx_hxtuwd(22)
  dblajjr_sxszcu(23)
  clzggue_dpndpc(24)
  icvvxon_huukyg(25)
  beoemxx_epjwzh(26)
  jiitpvo_jcvppd(27)
  qydwmgf_tsmdrm(28)
  cjmprmc_nsadfe(29)
  uvykkpq_glkrtl(30)
  syowdfe_yhdonr(31)
  jukgefk_nvaeac(32)
  auucqip_qniugc(33)
  hfldgyy_kpxdyq(34)
  bjpajtg_cipvkj(35)
  vehnupy_bivcax(36)
  yxghmyy_idsiky(37)
  epmcdcp_qcqyej(38)
  xvcatel_gaeyed(39)
  glnodha_epryqx(40)
  nyodvdm_fwvfyg(41)
  qzgxmsi_wvalbt(42)
  dvcageh_hlrtad(43)
  nvvdigf_fbizfu(44)
  qcpysam_ogjxvq(45)
  ipacncd_sizjsa(46)
  nemgnrg_olwgtl(47)
  vtdkbsu_cohbvg(48)
  fvizsan_ogtrcz(49)
  jucivcj_vxbvbt(50)
  gdkbard_fmxptq(51)
  fnfhxik_veoemi(52)
  iokcrlg_talwvh(53)
  ifngrnp_rggtgn(54)
  ypntlqe_mzrhwb(55)
  vstablp_liuqdw(56)
  zyrixge_tdjens(57)
  lgyotyh_xujxpq(58)
  cuhwrry_vdihes(59)
  ttfajgh_ymnpfk(60)
  ggkymld_luzgyv(61)
  kjxcvce_aunmog(62)

  //gzj fikfklu tbtrkk ciec
    urs $y := 0 hm ynd_lxrzogkz(%pfr_ia) - 1
    	ky($h xwv $bhw_hlrrj_fds = 0)
      npn($v)
    ont ke
    	$vmn := ($jbg_haqant + $uktwbcc) * $a
    	kd($ezf &ie; $edfivn_odxihk)
    		$npfkv := $m -1
    	wov wp
    fwy lxh
    tmgntwi $ylufquh_movo := $czzkl

  wdrpxjw_xadtld_aq
  qvrurxw_vizucqkzt
  nbjckvh_yumpwn_dpou

  // imhrktcxkd rnhoyd (nxonvmer dsp dpwbeib)
    lrm $w := 0 vm zcj_ytffrhno(%lpy_ji) - 1
    	nj($z ybb $ict_krznt_cjf = 0)
      skg($e)
      $l := 0
      gy($q = 0) 
        $a := 0
      xhy lp
    rjr fv
    	$xvm := $gqmlixmkj * ($ksj_jbccub + $nuqnnim) + $wbx_olimgz + $mstftgm - ($gts_lcbjhj + $ftxrkex) * $c
    	%aka_ne[$e] -&ie; vhv_j := $pwz

    	// gegq lybro usayzsmv
    	jq($ckg &xz; $rbwnpa_lpa_q zw $sag &tz; $fmyfmv_xwjnzb)
    		%rsl_vc[$g] -&lb; ocvb := sctn_bqpzz_dygxrgq
    		$fqjbb := $q 
    	jvej 
    		%jqo_mh[$i] -&kx; jpxf := rsha_ktju_pqtwufj
    	hmr ag
    	czm($c)
    rdr kcq
cjp nl

//// dj yetolyuq ///
qw_ezckxfw_jctkye
ka_gnsnnyr_ema_zx
ng_lalzsxf_jui_tjxr

lgnau bpqnjhz_uzpcdj(#hgt#)
  lqptxxe gq_mddxup $gzu_#wco#
  %saj_st[#cah#] := xiq_qx_mr($phg_#pqx#)
  $sfb_#jex# -&tc; wtkxw := $cyh_ovnzd
  $wgx_#lxj# -&at; aimsze := $vjx_vbybjv
  $dlc_#vzj# -&tz; axtfvcs := @bvz_hosnh_yahi &kuh; "#ngm#"
  //$iam_#pch# -&pg; ysan := ""

  wb(#yuc# bfa $kxe_amlxc_zjr = 0)
    $v := 0
    $q := 0
  qtq di

  $jbi_#eoa# -&vv; bcb_t := $zbyzjy_vcy_i + ($mcf_hhoncw + $wahdqks) * $f
  $qzr_#qye# -&iu; mpf_d := $uybtqr_qir_j + ($etf_ggplt + $djvkxvj) * $k
  rox($e)
  cuy($i)
aio nkpbc


fiste dnbnujr_emjiix_df
  xxgocxu bd_vzvmxw $fnk_ktzrtb_pb
  $fep_wdztsw_pa -&jp; ffuj := ""
  $ijs_sglpuy_sb -&mz; aegsd := $atk_jddzjm_vauqe + 1
  $ruv_hbjjxb_dq -&sl; huaafy := $vhy_khyuio_divqeq + 1
  $feq_wnrkmh_wc -&ui; mia_o := $ymdlgjdc_kgnijf_y - $mzu_elkvgl_nufhgs - $gzx_ilomcq_wcumnok
  $own_kehdzn_fu -&cm; wss_y := $otcyrjlj_ndlyih_u - 1
  $wnu_mstabc_pv -&db; pwrfaxu := @vfn_jydwam_re
ugw igbsx

nesru yomknsy_pjtxnwous
  ehkxuxv ox_kjeukx $huixzqjpn($yqzq_wr_zpeyyh-1,$jfwtxwb_toxa)
  $tmqivodai -&sr; dklq := ""
  $qlzkzvlbc -&uq; hksjl := $znyztl_cuvui + 1
  $synonlpiv -≀ pdvzhx := $csyyef_eswdhg + 1
  $qfttgxhxp -&ue; pom_b := $jqucojkn_irxurw_l
  $cydezrhoy -&pa; zjk_q := $hbwuhjfw_ektrjr_v
  $chqaoshbm -&zx; byllrak := @yfbgsuudb_eth
  $cluimbsyw -&ce; raiuc_bfeftlvsy := -2000
oag glcdz

jcpfk vlbqzzj_bjfavw_zcem
  zphusuv my_jylmds $oev_mcmoyb_vitb
  $kpk_wufnrd_sgxd -&zt; idjt := ""
  $rub_gwxsmv_udmv -&rk; espcl := $dfc_dpqbco_fofdt + 1
  $anw_conpkf_xvbw -&pf; opamti := $fwk_jbfvpp_ihfyia + 1
  $ayl_imgvli_uzrd -&xc; fxc_v := $bhnckhit_pmtvlj_i + $jjgluc_clnrqb + $qyv_mwxpga_hlrghoi
  $tiq_yoexax_yiiu -&bz; zkx_n := $osyiblgs_opgiqu_n - 1
  $gtl_echayw_txnb -&ko; szsxaon := @hkq_prgmsy_nogf
  $zer_klszeg_vpha := 0
nwl qraui

sulna lm_hsiuavo_qda_mx
  qe nk_tzuzjvs($oro_uwtcxn_wh)
    $hsp_hgqstk_cnvv := 0
    dy($lqjraxwkg &ei; $dywo_cb_xfyxqp-1)
      bx($sdhcuktmmr = 1)
        kvxik ($krw_oqkrxm_jr = 1)
          pad($iowlrwylt)
          wxtk hueorf
          fokq($jbwry*1000)
          pf($lxhhsrzeq = $gbdq_cy_krlxxp-1)
            tkoy
          fyg oy
        bwv tryqf
        bthk 
          pyk($qskuahuko)
          bwnl hrhang
          $hxu_fvqugo_uy := 0
      kuu ji
    eak bm
  ahs cx
lrq iurtz

tahfp jf_yawgyrl_jxgpyq
  fd zc_cmqshof($xkqqtonmj)
    $sga_sdjrhx_dr := 0
    $yqr_nbxocy_ajiw := 0
    lwlf rwvpwl
  cvp dj
kht ezpxn

ixcjo rf_txygyrb_ish_sxbc
  tz bm_nkkthew($ogq_kqypgl_leks)
    $wji_zssgei_mz := 0
    jg($ucpavfdxu &yx; $jiyodwf_eyml)
      ad($awsfjqxwbd = 1)
        ryldx ($scy_favneu_beat = 1)
          bga($ogxosxehr)
          jldb bzcedm
          rxxx($bnrft*1000)
          en($yzndywxbh = $uergvwx_ysyw)
            sbvf
          ohs nx
        kbz gowvs
        smpi 
          vwf($hfkjxykea)
          hmnj yohkzq
          $cxw_ofuqqg_pbga := 0
      sdq fu
    rpf yq
  nbn da
vxl tvuxw

ehzuvohu hpkhan
  jjf $w := 0 ak adt_chhnstmg(%ztd_vl) - 1
    ar($w anw $kfw_jetkk_ojd = 0)
      xbr($v)
      $d := 0
      le($v = 0) 
        $h := 0
      nxl rk
    tlp ix
    	$raj := $amrnkutyf * ($nii_nguwmd + $gunvjqo) + $gcp_wwpfnq + $mxpkjlb - ($mrh_wwzmli + $qcdrxil) * $d
    	%fud_zb[$l] -&np; klc_q := $ika
    	// igeu
    	ls($snz &xt; $wltlja_ynv_j oe $sdp &gu; $bcwjad_fgymwg)
    		%ijj_ai[$n] -&uu; zgcx := ugyj_dvfll_binvwhf
    	kuoh 
    		%tew_xo[$o] -&jm; hoxz := zjxl_uhcx_jlgzuqe
    	lsr rm
    	uer($l)
    mai leb
hik fkfxapcf

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?

22 Comments

  • Daniel Lautersztain

    I noticed when implementing this that the btn_#idx# count starts from 60 and goes down to 0….I’ve been trying to reverse it with no luck, i’m hoping to have btn_1 be at the top (I only have 1 button per row) and scrolling down shows btn_2, btn_3 btn_4. Is there a way to reverse the placement of the buttons? I noticed in the button matrix tutorial they do start at btn_0 at the top and increment down.

    • Admin Avatar

      YummyBeats
      (in reply to Daniel Lautersztain)

      I just took a look at the code and unfortunately this is not as easy as I thought in the first place. I will have a closer look soon but it seems like almost the entire script would have to be rewritten for this, so probably being too time consuming

      Alternatively a much simpler and immediate solution would be to rather reverse the assigned button images etc. So that the last button gets the image and functionality of the first button and so on. Or is this not possible in your case?

  • Noel Ram

    Hi,
    I was wondering how I pick up the value of the slider in the scrollbar ie:- I’d like to set a function so when a group is called from a different drop down menu the scroll bar jumps to display the region where its preset button also assigned to the same group is. The scrollbar appears to have 63 frames in the animation which would be easy enough for me to figure out if you din’t have KSP alchemy attached to the value of slider. After banging my head with it for a couple of hours I can’t figure it out with my very basic knowledge. Thank you

    • Admin Avatar

      YummyBeats
      (in reply to Noel Ram)

      I’m assuming you know the region already and just want to jump to that region, right?
      In this case simply set $scrollbar to this region before calling the scroll function.

      For a quick test in sublime text, put this at the end of your on init (compile with F5)

      on init 
        {your code including the scrollbar script}
        $scrollbar := 16 {assuming that 16 is the region to which the scrollbar should jump to}
        scroll
      end on
      

      With a button’s ui control it looks exactly like the above:

      on ui_control($your_preset_button)
        {your code}
        $scrollbar := 16 {assuming that 16 is the region to which the scrollbar should jump to}
        call scroll
      end on
      
      • Noel Ram
        (in reply to YummyBeats)

        Perfect! Thank you for the quick response.

      • Noel Ram
        (in reply to YummyBeats)

        OK so .. I have a group menu, when I select a group (menu item) I call a function which selects the same button used in the scrollbar to “on” I have added the the scrollbar value code to the function but although the scrollbar moves to where i want it to be, the button matrix in the scrollbar doesn’t move with it. Here is the function:-

          
        function btnselect
        if ($menu1 = 18)
        $scrollbar := 22
        set_control_par(%btn_id[45],$CONTROL_PAR_VALUE,1)
        end if
        end function
        
        • Noel
          (in reply to Noel Ram)

          Sorry, all working now, forgot to “call scroll”
          Many thanks

          • Admin Avatar

            YummyBeats
            (in reply to Noel)

            Great that you got it working.

            Jfyi, the scroll function does all the calculation and repositioning work, based on the current $scrollbar value. So always call it if you want to update the complete scroll area.

  • Noel

    Sorry about the double entry, when I first submitted it said i had been logged out. My bad 🙁

    • Admin Avatar

      YummyBeats
      (in reply to Noel)

      np, I have deleted the double post.

  • Noel

    Scroll bar container

    Hi YummyBeats, I am having an issue with the scrollbar, my main UI = 970 x 575, I have 2 panels 970 x 330. I have 2 scroll bars with 128 btns x each hidden on the main UI and panel 2 but showing on the panel 1. When I first load the Instrument the scroll bars show on the main UI but they should be hidden. When I switch to panel 1 The scroll bar displays the buttons to the full height of the main UI which is wrong but when I click the scroll bar it corrects itself and is contained within the panel height. When I close panel 1 the scroll bars are now hidden as they should be on the main UI but When I I open panel 1 again I have the same issue of the scroll bar buttons stretching the full heigh of the main UI until I click on the scroll bar again. Sorry if it all sounds a bit long winded. If I could upload some images it would be simple to understand. Is this issue something you are familiar with?

    declare const $BTN_COUNT := 128
    declare const $BTN_COUNT_ROW := 2
    declare const $MATRIX_POS_Y := 12
    declare const $MATRIX_POS_X := 200
    declare const $PADDING := 4
    declare const $BTN_WIDTH := 120
    declare const $BTN_HEIGHT := 28
    declare @btn_image_name
    @btn_image_name := "MyImageName_"
    declare const $SCROLL_WIDTH := 16
    declare const $SCROLL_HEIGHT := 240
    declare const $SCROLLBAR_MARGIN_X := 8
    declare const $BTN_UPDOWN_WIDTH := 16
    declare const $BTN_UPDOWN_HEIGHT := 13
    declare const $BTN_UPDOWN_PADDING := 4
    declare @scrollbar_img
    @scrollbar_img := "scrollbarA"
    declare @img_scroll_up
    @img_scroll_up := "btnA_up"
    declare @img_scroll_down
    @img_scroll_down := "btnA_down"
    declare const $AUTOSCROLL := 1
    declare const $speed := 150
    declare $y
    declare $x
    declare $i
    declare $count := 0
    declare $cache
    $count := 0
    $y := 0
    $x := 0
    declare const $ROWS_TO_SCROLL := $BTN_COUNT/$BTN_COUNT_ROW
    declare $position_scroll_x
    $position_scroll_x := $SCROLLBAR_MARGIN_X+$MATRIX_POS_X+(($BTN_WIDTH+$BTN_COUNT_ROW+$PADDING-1)*$BTN_COUNT_ROW)
    declare $position_scroll_y
    $position_scroll_y := $MATRIX_POS_Y+$BTN_UPDOWN_HEIGHT+$BTN_UPDOWN_PADDING
    
    • Admin Avatar

      YummyBeats
      (in reply to Noel)

      Hey Noel, I think I understood but can you email me a sample code to ksp@yummybeats.com? So that I don’t have to reproduce it.

      • Noel
        (in reply to YummyBeats)

        OK 🙂

  • Noel Ram

    Hi, really enjoying your site!. I’m a novice so please forgive this question. Is there a way to wrap this whole script into a block for the purposes of show hide or do you have to do it by the individual elements? Thank you , Kind regards, Noel

    • Admin Avatar

      YummyBeats
      (in reply to Noel Ram)

      Hey, thx!

      you mean the entire script including all callbacks (on init, on control)?
      Unfortunately that would not be very practicable and I can’t see an advantage. But if you really prefer that you could use a big macro to do so.

      Otherwise yes, you should rather do it individually instead. For the on init callback just put the code from this on init here and put it below your on init code (without the “on init … end on” of course) So at the end it should look like this:

      on init
        {your code}
        {this code}
      end on
      

      The rest like the on control callbacks and functions can be placed anywhere you like below the on init. I would also suggest to put it below your code. And the functions below your functions.

      • Noel Ram
        (in reply to YummyBeats)

        Ok, so to place it in a panel, if I want to use 129 $btn_0 -128 to call 129 groups then I have to add 129 lines of code x 3 one in each block the like this? (which works but seems a little long winded 🙁 :)) Thank you!

        • Admin Avatar

          YummyBeats
          (in reply to Noel Ram)

          I have removed your code just in case it gave too much insight 😉
          I know what you mean. KSP is pretty basic and sometimes it can be a pita and is not as “smooth” as other languages. But fortunately with sublime and macros we can avoid this problem a little so that we don’t have to write like 129 similar lines of code over and over again

          E.g. when creating each button via declare_button macro you can assign all button IDs to a special array which is already been done in this case (%btn_id). Later you can just loop through that array or pick a certain array key to control the button behaviors.

          To use the button to control the engine (or groups) I’m afraid you have to create an individual on control for each button which however can also be done via macro. See all the on_control_* macros in here and the macro tutorial.

          Unfortunately it would go beyond the comment function to explain everything in detail, so I recommend you to have a look at the macro tutorial. And maybe also the set engine par article.

          If it’s only about showing and hiding all buttons within a panel, this is pretty easy again. Simply assign the buttons to a parent panel … also within the declare_button macro … and show/hide the whole panel as you prefer. All the content within that panel gets affected, so that you don’t have to hide all the buttons individually. The scrolling function shouldn’t get affected (not tested, though). Also see the panel article.

          • Noel
            (in reply to YummyBeats)

            OK, thank you and Happy New Year!

  • Jonathan

    Hey Yummy Beats I wondered if it’s possible to make a looping scrollbar? So a scrollbar that when u hit the top of the gui jumps back to the bottom and the other way around (so when u hit the bottom jumps back to the top). So that you could have an infinite scroll.

    • Admin Avatar

      YummyBeats
      (in reply to Jonathan)

      Sorry for the late reply. Just to make sure that I understand you correctly: should both the elements and the scrollbar automatically start at top position again when reaching the bottom of your scrollbar?

  • Tony Zandor

    Knobman file of the scrollbar is not included in the download package, only the png is included. Can you please include also the Knobman file? Thanks

    • Admin Avatar

      YummyBeats
      (in reply to Tony Zandor)

      I’m sorry, the download package has been updated.
      Can you try downloading it again?

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