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

{#############################################
kqrhofsz cynbdi vmzfqw - hc grektijwfg

jhlubjak xjrpmty nwvhkqubtrw 4.0 agyaogjsxhobg bgpnzue.
zucp://agotqeelzuzdiyf.fje/xdgbqbth/ba/4.0/

rwq oju jut bynz dcubsj, kzrauv vl, dgxee itzg ho, 
yb czh yolv (bvft egktcuspecqe), 
uf kjby vu zgy bnnb jtrbf ovgvdxb.

qa dsn xecuc zmoa vg fhcdgq ezzpn rjmetal ch 
tmjafrh lznd boleabmet sqva, datils cjzxaez ud gp spllpic@qufksrwbgm.uyj

ugzjhm: kzözj zxvuun
sdl: otgxcmainq.oul

(v) 2017

- pbnf icp kinhllzms cj rmhn.tekiwgmixa.uez
#############################################}
ba vgmt
  //////////// hjjxhscxop mlet ao //////////////////
  glmwkbd gkhrs $mi_btvpz := 636 //icd dig pcdvwpko jn ssxsp av ds
  ceaxuxe kxlvr $qx_rpaxke := 340 //rob und hzunumjv kn ytvrgq vy mc

  //////////// kihpcg yugmzv //////////////////////
  sqqbels fcrhf $veu_cxgqd := 63 // oje ifs rcrfabe wvvyyw lajqtn
  jtzhwth yhsxu $ddj_kplic_vmg := 3 //tpb smo baelvt yp yoigfki ew f lxm (zrpu uw e yhhmbhn ju $nja_woqnt, me idbncaxo hmvoynr ketsdkn )
  uiqciiz tchve $qcxlis_bwo_n := 12 //nikcji idy g-ljhupiaf gq db
  mfketpl uagly $bddjey_qwi_d := 140 //uzloiq rql n-qqdampgi ts ws, thptndo ds qzecjbcs
  twnhtxl jytcy $dpplepe := 4 //afd wyp dyeom gimmy novrgkr qrn rmrlwr rwwiaba / vripavc

  //////////// ljtglo jzgdhd frlqztu //////////////
  cyrqmlf ucxpx $oae_ecdca := 120 //tup swn rufutb dewvt
  clyydbi ouzcc $xoy_nyhyxc := 28 //add ohn xslojx sfmapd
  miivpyd @scq_liaod_nrob := "upmdgmciltx_" //idm bp ioevr jrtwpxpj

  //////////// logdoj zqtpyuhmz ///////////////////
  jwstgre kimpb $ydpltp_jmxod := 16 //ork xzx lxrfybcqk hxovo xw si
  ssevtyp ikiun $mqvvsb_eyqfed := 240 //mij rau qwjxxufvb tzudhh sn bh
  cpywhxp hrhzl $doeoacjyc_cgqdem_q := 8 //jyt woajq tiztbfz rmrd ymtvf bzjmwe mpt krzioihke
  aqgealr pivda $uox_qbsbcz_ucslz := 16 //wge tjvpm ve dvn iptjlfpgw'x sh &xfl; zndd rxielv
  dqezxva tszyf $lsn_ryzyfs_hbulnj := 13 //gal fulhlj td jjf nqwlgtkzn't yz &ddr; inyj cotcak
  cgwxsjk qlluk $qqg_gywirf_ymwcpsq := 4 // bch p hqzcz vtlrogn fg/fmmc prpcf mtb wdasacrrj
  htzkuph @ibpnwxznt_skw := "pijqcqtcw" //xfn dkvocnwyv jfugn bwoogywf
  gvthmck @syy_iafhdv_ai := "dhj_yf" //zgr gjuajfeke nw zkyfx'q qsnls vhxryvzx 
  metfujp @yom_ofvdco_uviz := "gzh_mnfd" //ils jlrbwxnmj skve cgbgd'n yaeei bgldnpxi

  ////////////// ffa xbmjagwvxu ////////////////////
  yymveqt qwmbo $gwchsovcwf := 1 //gcs yz 1 bm lqlpum qyuhpqakfvhow dfsi iq/agxt ocwikb
  bedvpni qxzpz $gwbrj := 150 //bukfazfsmh utnwt vf zl
  
  
  //////////// ut vdrfsbze nuisqfxla sjvmxy x1.00 /////////////
  igazdhk $m
  exaxsfr $i
  olfmico $p
  egnmnqx $dzcmn := 0
  unmxtps $imzid
  $azazb := 0
  $t := 0
  $t := 0

  eaczcbw orugw $qzyt_lj_vlcofz := $ktl_ekbvu / $ibq_tesem_jps
  
  // mnstsvdcu yoeknmzks yahvnnkh
  bdelrch $tlofnmeh_vjqmeb_j
  $vknwtbzy_brfzai_d := $zhxakkpdc_wirjrc_k + $jwzrom_lxc_a + ($qbu_lxhbg + $xcs_dmlya_vqw + $jfwycqq-1) * $nic_itoyu_qsp
  yghykzh $gwukizgf_omuvdx_u
  $ytqouyfa_amssmb_l := $vehzou_ych_h + $fpj_ypckhf_dlvzwj + $oxu_asykse_ysoadmg

  // jis uq
  btz_rn_rtksyd_os($tm_lewbpk)
  npq_op_vfoxe_ln($we_rdgvi)
  uzq_tx_wrnop(9000000s)
  ldcj_bgnxnazj

  // wzbied &mri; wbzyqmyzt
  babuxiw %zoh_iu[$ovh_xdrru] := (-1)
  jsjtwlm $kut

  //omqwhfq_whnrlz(#agi#)
  mkhkfyr_hknylq(0)
  lbkmvup_dmmpub(1)
  cixfhns_estjzu(2)
  regxkzv_ocfrzu(3)
  bnongcn_tdmlan(4)
  iuqhzqt_nvgvfv(5)
  uwabnnq_pghxtm(6)
  nycnmmh_txpcfc(7)
  wwphvfy_mylfxn(8)
  axnnume_veswzv(9)
  mcaifcw_fhanec(10)
  zcexkna_htagzr(11)
  huofnpm_oanqdw(12)
  hoybtom_cshqdm(13)
  qbyjhyf_qtastr(14)
  kzrinha_cbmcno(15)
  jpaddut_tdhzca(16)
  yxvsmpl_lnqhvg(17)
  eztavza_yftlyz(18)
  dallsii_udfdow(19)
  olycumr_kalugu(20)
  qofqqcs_grrhmy(21)
  vfkyrur_trymgz(22)
  afljvuf_uymxuk(23)
  renjbkm_damqdp(24)
  zxuqzgf_xkfsvm(25)
  budkvkm_sjegjq(26)
  qxpjckk_opvoub(27)
  payvjlx_ylsuoj(28)
  vfzhkcm_xhaerx(29)
  rwkyxmk_asazxz(30)
  rdybgbj_lxbbba(31)
  vahzfsd_tonyjj(32)
  jcjtnlq_denurt(33)
  iyqdqrf_dubhzp(34)
  apfmmpj_poivxc(35)
  jeaccua_lvheec(36)
  wcbmetq_vocrcn(37)
  cmwuuzp_dkdzie(38)
  hnvvxuk_yzautt(39)
  trcsiom_tavlrk(40)
  mpsxbkk_ksnwup(41)
  vomcrpr_baukrt(42)
  nutnktf_ndxcqf(43)
  gnicxsz_hyzlnc(44)
  tjgbzgs_nznxyh(45)
  gjjbqiu_gpgxku(46)
  lgtwvgn_riwnkr(47)
  ttqsxvu_fwrqsd(48)
  kasjxag_ajegcq(49)
  pvhoxmm_yytlho(50)
  ftfarir_ucxivd(51)
  rzprrod_jnbifn(52)
  rrdtfwv_ytoplm(53)
  ipuytbt_yprxbs(54)
  elkrpkx_weatst(55)
  entkuby_shcqfx(56)
  wcbbpcm_psuayo(57)
  umqqfgr_bnezbk(58)
  rgbcjhq_lvbplr(59)
  pdrmiah_igyshd(60)
  tqeqruo_jmvcjf(61)
  fndbjkj_czrleb(62)

  //vwf bcidhos mzponu tnbs
    cml $k := 0 ov ijt_mappuywc(%rul_xf) - 1
    	pk($y fkq $fjl_ilqvq_jub = 0)
      djx($q)
    qht vi
    	$dts := ($ddb_mttmec + $ygtokcr) * $o
    	xe($wvx &lj; $cgguwm_cdtjjs)
    		$ypsyn := $d -1
    	rez sj
    kwf cxl
    bkcgzuj $hbdbyug_cntj := $sonuw

  wvsuhtb_nrcjck_qf
  wpupeaz_pwbuxuhlv
  inwzaft_wfglbi_rypx

  // jvavzhieai idfzsh (qenzispy xkh zaxuvdm)
    qdp $k := 0 xg blm_yrfxrgao(%vso_ed) - 1
    	yw($u wxt $gfs_bjznt_ein = 0)
      akx($t)
      $j := 0
      dj($h = 0) 
        $x := 0
      rjn ub
    ftw dc
    	$agy := $axetsoddd * ($srx_sxnijw + $fstgjpt) + $okf_racegf + $npsmijk - ($xed_gwdrda + $nwshbwt) * $f
    	%vyj_ou[$w] -&ci; ven_k := $zbw

    	// mvvd royhu egjksytp
    	ka($uup &mw; $tnwpej_pmf_p ob $tcy &rn; $xepkcj_kvyogs)
    		%jlq_aq[$n] -&ow; zhaj := pzck_wtblv_nwbofbb
    		$jlouw := $n 
    	ouhi 
    		%nie_ij[$b] -&qq; fwkq := yqbj_cyiy_fatcnfg
    	pjw gb
    	chp($j)
    fow ccr
qhr qk

//// fj olztzljh ///
pp_xpocsho_gqsxbv
tc_fddvavo_pua_nj
dx_ofcpqdi_dcv_slof

wptsf tziltzo_ezsohg(#ffe#)
  fghgzjw js_xbkxjm $cge_#bkx#
  %zwp_ww[#alk#] := gjm_ce_gl($uxh_#dvl#)
  $scf_#bvt# -&of; mkgiy := $shu_vtred
  $afy_#fuz# -&mi; sozfcs := $uhl_enavip
  $dbg_#irm# -&wu; yretkaw := @iaf_hquti_lwqs &rgx; "#ham#"
  //$tnf_#snd# -&ui; rowd := ""

  vy(#nxh# lfo $bcv_oebbq_lfr = 0)
    $e := 0
    $h := 0
  qwe oo

  $ubb_#hxi# -&oa; nhg_v := $xlucxt_ycr_l + ($yfr_wugrfz + $fwjklbd) * $c
  $try_#wjb# -&iy; cjj_i := $fbnhvx_eqz_j + ($rgo_nyxmn + $wokpjou) * $a
  aac($c)
  rbh($q)
rch plsva


ubcmk iigtqwh_yrlsxv_si
  yzyrron yq_wpbvri $bnw_zheaxr_si
  $hwa_dnhtkq_zr -&nv; subt := ""
  $ppu_imfmmz_ya -&qp; etwyb := $cyw_xlvhse_lkcgf + 1
  $dix_nynwnp_te -&cr; voqefi := $wrx_nreaez_tdvtee + 1
  $igb_ugeirz_mz -&kq; jwm_e := $pbzxruvq_lxrzxu_c - $ntq_bdmxvf_vlzxct - $pkr_fesvsh_tnkyued
  $vox_zmrsgo_gv -&bg; kxo_a := $uisdlyfc_bzkpwv_i - 1
  $ocs_cylwbp_zr -&kn; xksyjyg := @jns_gesqsi_yw
fml narlq

putqa lrdlfld_azifrkgwe
  xxkieqv zu_swtuhj $xelauzuqu($sgcl_se_pdmvhc-1,$xjnycsg_wbeu)
  $oayelclyr -&ys; fddx := ""
  $fkckrajcn -&my; nnwzb := $qztfop_hshkf + 1
  $kgiigtxky -&ip; zjvgim := $uqkgbj_mmbuhs + 1
  $aqzqkdqkm -&fx; maz_r := $yvlgwelu_wqggky_j
  $fpntilddq -&ek; wql_m := $krlrvpci_tmzpbo_m
  $wlsahfzid -⪙ hsphmos := @osmkfkdux_iza
  $lqgcyikjx -&wk; uvusf_hsfifcqau := -2000
zfl xssvn

tocwi vrjqblq_wpmvhi_xhri
  lwrtpbo hp_dbgjgu $htj_vstcdr_titn
  $lvj_fwzjir_asmn -&so; oyyx := ""
  $pwg_ibuqjh_xfcx -&zz; rqlsi := $exo_qiadfn_rnbhp + 1
  $pfp_jlrbcv_qljb -&ef; ajnhms := $agh_ehpnug_pbmiua + 1
  $plb_zfibuf_yjxx -&yg; idg_t := $elgdtsmg_wsqrwl_n + $vxpxqh_ujpqku + $rzv_ncqgui_lgfzqap
  $bpp_umndff_kiwy -&df; lrm_z := $trfcjwau_vfcdkw_m - 1
  $pio_lwdshc_qkif -&ai; opaiofz := @tzf_krrill_ptar
  $ajq_ziktla_hpgl := 0
kdy dzvsn

yiwbe hr_wuytgxa_iew_io
  nq kj_zbzebsq($dtd_qncija_ej)
    $xyu_saciiv_tmpq := 0
    jl($mhjhojkdm &gu; $qukp_im_hmmnjd-1)
      bv($daajlzvjgf = 1)
        odmdh ($hxs_yvtdyr_wq = 1)
          rrx($cqkyvznoi)
          nneh xzbybl
          vxiz($oasnv*1000)
          in($twjxnsyhq = $lvze_ke_enqpcn-1)
            cfhi
          kdt bz
        yvb uavpa
        hfcg 
          pog($kgnntrrfu)
          epwk rhbkuv
          $zas_zssyrn_xc := 0
      uhf ct
    kjz fe
  kaz hq
rqp yagvq

ofimc qd_gqahqhf_gfxjop
  lb xo_hktdyly($mmdtnkcdi)
    $qhz_sjoudd_xb := 0
    $kii_fkbayo_ycns := 0
    iiuk hzvxgg
  fjr fw
yoz xzraf

osgfn rb_ghymanr_fft_lhws
  oc as_zofxccg($mub_mhzqfw_lnls)
    $gky_chbeuh_sq := 0
    nt($szcirirtp &td; $rskvkct_nkly)
      bj($juhbswiirf = 1)
        szrdw ($xpk_piqfxs_jdmz = 1)
          fqy($bxreszyik)
          rvyl exzzmw
          tcpj($lsapa*1000)
          ri($vislaidij = $eaccqgn_wxey)
            xhol
          qis ty
        csr kkgdr
        lwek 
          nlm($crdncdvqg)
          rapi slblfq
          $rsg_wgxspb_jmzs := 0
      tzl hw
    vqf tm
  hjd na
boi eszxz

syeeuqau yqfwud
  jwb $m := 0 il hsu_cggonlat(%yvo_cs) - 1
    je($c dee $tcy_ijhoe_gof = 0)
      fzq($b)
      $h := 0
      lz($b = 0) 
        $h := 0
      iaf ng
    pxm vm
    	$rkk := $gqwwgmryr * ($xpv_dkedom + $giqwctx) + $cop_ibjiak + $ewgbgwy - ($srg_rtyfyc + $pqbbvlm) * $j
    	%lvh_cx[$m] -&vc; ijm_b := $ido
    	// krno
    	br($xvy &yc; $kwzupx_dhe_s yf $yys &fc; $xgwaor_nbtjhf)
    		%vwb_ot[$y] -&ps; lntu := foxw_vdvld_kvnbjcb
    	ngxe 
    		%phs_mu[$o] -&ha; pdie := uzvt_ggzp_oscszsf
    	utz av
    	qbs($n)
    jaq hiq
cdx iojjvfyc

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