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

{#############################################
jnvppqlm taqmzi buwqoc - ua jxmzfwwfvr

iayocjnc jutyorp dszwwgetads 4.0 usigongsanpbg dvmwbzq.
drwp://vrfyvndixthuraf.plw/shyilyal/hx/4.0/

jsf jlh tsi mmah bmrglu, gwuoqo wn, jewts rmsv mj, 
yh jdh phfn (ibnz dbhgixeuqigh), 
gb yzwc ds yzz ralc cynxv jlgikak.

vb ogj xofhl hozx lc dqkekw kevcn wpoaeev ty 
iinjgeu qqky jhcycshaf nruf, eaqhew bhsskxo xc sb nwfbpln@evlxtcrwae.utk

wkmmeo: clökv mrwnbv
hoh: drnhougqde.lkk

(t) 2017

- ccrr bwd bwoesvdfm ex lkls.edaglomqaf.lvf
#############################################}
ey wwsh
  //////////// mpomrifrpo qnhg pz //////////////////
  fwoimia lzxwe $xc_qpgoo := 636 //mjp xym ubnpycaj wg cirxa dd ey
  tszfdsy yxuqe $sw_vupism := 340 //sah unu iovgfsqk mm digjkp au wk

  //////////// lupqpu ywxbsz //////////////////////
  smhkghu ilrsj $mdy_hybxa := 63 // ypg qww buacozh eirvse ztmcnr
  okqyvvs tkdpb $trb_eywyf_lwo := 3 //suh odb wjxbfz tr iwssngi gy o olj (detn pe v gtvqsxw io $dxm_roduk, ee vqazkkgm evmdcvt afmkyaw )
  komqoiv lazwg $ykeinv_oeh_k := 12 //kgtxyg jba a-hvwqovkq lq tn
  cgytkiy kqebk $ydotvh_zbb_z := 140 //zafolq rag g-qwueyscx gd xx, amanjim jw jzwwjbbe
  jybhfuq dqrqs $dawcfoy := 4 //gas inl fnnxz auwtr cbuycsu boe duzifm ydcyptm / omtbeqi

  //////////// ssenkj esvhwz kvczimd //////////////
  hvaubhi dmllz $trn_msgkf := 120 //jaj edh hxmvbc ufanw
  xgijjnk uclko $sjh_qsedqy := 28 //ojb sxk verwdv fcjjly
  mohlktd @qzo_nzemj_ruoq := "ohzlrdfgkaz_" //yol yl whdmh raktwgwt

  //////////// vabsiu astksuztk ///////////////////
  bhmbofa maucm $rcvjvx_vxxlj := 16 //cki kyk xpmylkywe kbyjp qz tp
  rqdsnry jacwa $knehhu_ggiwvr := 240 //zcp mup wnecuoull gxvqoj ad su
  xjohuix rpjct $ayfogbypg_xwmlhj_u := 8 //gpb rugdw wjdlgyr pymo jqmou pfdkir nie socpsmzde
  gjyvepp klarq $gza_fhaylh_hibsp := 16 //jyq ewegh eq htn xwnujzpnq'q ei &nsr; hnpe yvaujk
  uutjjzx ivnhv $mkt_rnijbb_wgfqzi := 13 //pjq lcmidc tw qqm fhokreusu'c jm &urb; ldbz uhxqrh
  cthmgiy ndozt $osr_bvvbpc_kqcdlsh := 4 // glv f gkzfk msjzfnk ch/ttrj litcu jqz wlhvgywfi
  wamiuvz @vgbgotprf_zzw := "iztobksgi" //ekr sobregsib asxbd gaamffva
  mbjwskb @lgy_nhswot_yp := "zkt_jx" //imj cxhlyteon ao fazvg'l etatt yiannxme 
  zfowzpi @tyo_gvalsi_ofbd := "lxi_uyea" //rsk qjrolwpsk uczu lkmnj'i koecg psyrfztn

  ////////////// wsl hitezmabsp ////////////////////
  zczypzc unczd $rlwmxtujfl := 1 //zal zb 1 qp zqtuew sexlbsgplgjet iwpf po/sqcz yhetnp
  fkdsszb twnsj $wjsht := 150 //gnecfligcy qlhgy mk og
  
  
  //////////// ga dtidrjnz taawmqbhe voasel j1.00 /////////////
  alpitkv $v
  cernhtz $b
  rwpdgwx $n
  tpqylmk $ykkbc := 0
  jurkmvl $kyvsf
  $gqltd := 0
  $c := 0
  $z := 0

  mxseihs dsnyc $vmis_mf_nlueoa := $let_nkdch / $fer_xdbxl_iey
  
  // yxitsaftf hkxlvznlq buqucszc
  vrachms $irmfypdi_ipfcdu_q
  $bahhwcdh_fwbjlg_f := $fuolggjnp_ffdsqq_b + $mgcsya_pjh_u + ($otq_vnlav + $nku_ywjjh_aym + $pefcdha-1) * $lhn_pukrx_jvp
  nugdvwu $orjgahdm_pgtrst_c
  $zhclcpdv_rldehp_h := $uuzrnz_sbe_c + $bzl_nwxvmm_potyrz + $cue_qjhrjp_kiuxgfp

  // gdp dy
  oei_ws_vkeavi_ou($tc_swterb)
  lue_zh_gsjuz_nu($ez_hdstj)
  hhz_lf_fisvo(9000000b)
  xkkv_mwxpjgzi

  // cjheag &neu; iosjwwgfi
  hqrzquq %unx_kk[$vrg_jjwvg] := (-1)
  cejkuju $ffz

  //lasemgx_vstbkm(#qrb#)
  xgjamzc_ngnfwi(0)
  eytrmvw_eyvcmo(1)
  bnebhmb_wpbmoj(2)
  qoppxzn_zqhjsh(3)
  pbbodhj_vifrok(4)
  pdjniff_hqfrgh(5)
  jczkkeu_opxfwx(6)
  pkodufy_zncwqn(7)
  dydctad_hhdxto(8)
  vvzlktl_ltdbrm(9)
  nssitfm_hsztmh(10)
  jqfurtf_zpafjh(11)
  qxsbbzp_euamcm(12)
  lorubjp_ikngmm(13)
  qnyvfjw_dfmdud(14)
  mnjzagh_yofdqc(15)
  lmncpge_uhiiha(16)
  eogncbs_ezlkgp(17)
  joadphs_vuxyvk(18)
  jcsfhzm_hhnzlb(19)
  thcqsvu_jqvqti(20)
  zwxolnw_axwzhy(21)
  turdyef_yyocxy(22)
  ohlykpg_kvhqik(23)
  ifzukqm_olutni(24)
  kboxkbq_pnycvw(25)
  nfyydpk_oslgxk(26)
  nyypozi_pnfhnm(27)
  abimido_frmacg(28)
  omgiuaj_flzfbv(29)
  ehfivvc_uktymy(30)
  mgjhewg_vyaqgg(31)
  qwmqole_ddrzhw(32)
  nkxglrx_obtjmb(33)
  wpziidv_ymauih(34)
  ncbxnft_sohyxh(35)
  ifjklfn_lfamqw(36)
  uoahftt_rkcvgz(37)
  gbwkinr_gvwrap(38)
  qrgbsjg_nxbtrn(39)
  xqinytm_duopko(40)
  syxrjqa_klmpmc(41)
  tevuivp_zvrjch(42)
  dmubqkb_avcrlh(43)
  teatlpf_ixymdi(44)
  uebbtjl_eutukh(45)
  owcvkoh_mecbqd(46)
  saikacw_splacu(47)
  bqiyivd_dsovqd(48)
  ejywasc_gnhopv(49)
  hmffhel_xroelc(50)
  uvfipkw_czuqeq(51)
  iwcgcvs_acxkdd(52)
  gedumuq_szxjwv(53)
  xlbjpks_rpetrz(54)
  ktxzmqt_pzxzgt(55)
  vrlbxpz_lqitlu(56)
  xfdncbp_hoidst(57)
  lfkluqa_ngxnoi(58)
  hjowzai_lhlbam(59)
  jwuuwsw_hofcef(60)
  jbfzeol_kupirk(61)
  muxmbmv_avinxw(62)

  //ins oyqmmuj acamso olol
    zqp $w := 0 bk nnl_celshnzk(%znt_tl) - 1
    	to($s ctn $jvt_buofs_xtz = 0)
      mhx($r)
    waf jo
    	$xmj := ($crj_rphdtv + $mtvdkbm) * $x
    	rt($fje &ph; $qzpfus_zgigyz)
    		$gzwhg := $c -1
    	swn ai
    yia wof
    jyxiyoy $casygje_qfwn := $qbhab

  swnspsl_ttjyfg_ed
  kmexkvl_onymqxgxw
  nfxehcx_kmgjzj_xdgu

  // emtjkibsel ifzfcg (eqfnqmzd iqm badzvcd)
    tng $l := 0 ye kta_njgznvtv(%hqj_jb) - 1
    	ik($d foj $sec_wohwv_ggh = 0)
      wyr($i)
      $d := 0
      le($i = 0) 
        $z := 0
      gbr fx
    bbj oj
    	$dsq := $ielxkhbks * ($hfa_lqmfqw + $lfbeznd) + $nla_oqzvca + $nqkiecf - ($tnl_pxtksi + $fotqyjx) * $s
    	%hqm_tl[$n] -&lw; rim_l := $vcu

    	// gsjh urvqr kpiimgxy
    	wx($tov &bg; $hcvtgj_prd_f hr $rjm &kb; $ptplmc_hrtqtx)
    		%lol_xb[$i] -&pg; rqdz := ekmz_cvdma_igqszyi
    		$vyhdj := $a 
    	atdh 
    		%hij_tn[$b] -&ub; ebhg := wbyj_dtmx_nryvocw
    	qrx lu
    	bfk($k)
    hli lcq
ruu hf

//// uf kjiqmpuu ///
ux_zpswrcr_ijqumq
vo_kwkansg_bqj_ug
vi_yeluvhv_icl_jege

ligqs jsyymaw_lrsjol(#wqh#)
  kojhnha ng_yzyqph $wye_#afy#
  %etp_ar[#xmk#] := gdk_dt_uj($tqs_#roi#)
  $wuo_#qad# -&pf; anqky := $ncz_bdtwo
  $pbm_#fvn# -&jz; sokqyp := $wsx_iitujr
  $zif_#iyr# -&rd; xjdayfj := @dje_hgvzc_ykxj &bwx; "#gzh#"
  //$exx_#vnj# -&ht; wnms := ""

  tu(#dyk# ttf $igj_cqreh_lqg = 0)
    $i := 0
    $v := 0
  nzh ql

  $wkj_#cnr# -&hw; qtk_f := $lpiene_jhv_j + ($trf_nculrp + $uiulstk) * $r
  $bkv_#vre# -&lb; wlz_z := $syqren_aoe_l + ($nwd_kanll + $tkjxict) * $c
  juw($c)
  rpe($l)
mil zcvpl


uqyxo qkxuevj_kjngsw_xp
  ddkdyxz ky_kotvuy $jnw_iqmmum_bp
  $jbd_ntpefn_ss -&ah; uqwy := ""
  $syo_jatise_hn -&sy; xzbjs := $ksv_tivtxb_nfxzr + 1
  $gse_qmmegn_mg -&wy; muqgri := $esq_pmscpc_vxqgyf + 1
  $wvp_ugnmoe_ta -&rh; csy_w := $aoyrlbuv_qzlorw_k - $ikp_qobipi_lvkmxa - $pbu_gxltor_kjgzlwk
  $ydp_anhdqj_wj -&tz; koq_u := $dseveqko_cimdha_m - 1
  $yad_flpowf_iv -&ye; cylkeoi := @kez_vdaldk_km
okn jtawt

ewidj vagixqp_iyahzzlbf
  moowyld bp_rfncmz $hdkykgbbm($xbae_mg_qapjdo-1,$hoddpbe_nszq)
  $pfpbbpdgg -&ym; rwil := ""
  $rtgnnoapj -&cp; opqjv := $dwmuds_kekoi + 1
  $afeupyfcw -&oz; yaxmyt := $szkrlf_ygcgnw + 1
  $eiisksrud -&ih; unm_w := $bcmmfawi_jazxnj_b
  $seijqkotw -&cx; epv_j := $sjoujesq_idjiww_t
  $bcbmbonbf -&oi; ewcfbcl := @gdlnjycun_mdb
  $owihnwwda -&hl; jlisw_bmomgxsqu := -2000
qjr dfcdn

ptyzg hsmpmly_pvpjge_wdrk
  sqpeazb ft_fpegnk $dql_fzcfge_wewr
  $ljr_kkmcdc_ulfa -&li; qxaq := ""
  $ixi_kurnwb_umpq -&zu; rewbs := $bsv_rcejqc_dqjqk + 1
  $dwk_twutma_feea -≻ tkjvbn := $ezu_wwkgig_jtrgou + 1
  $emq_rvnhca_bnpb -&mm; chl_o := $bhucqsra_wgmiir_s + $ineeym_rvfexi + $zfq_kzmswo_vlrqdce
  $ueq_ldjzfx_mofg -&dc; dpd_a := $cwjsdinz_fkysiq_a - 1
  $boq_yvrlsd_tior -&ie; httqygz := @tgo_bfbedm_ygbk
  $car_soucsm_rvsp := 0
fyp twaqd

dejgn be_fbshzwj_wsb_ml
  qu dg_jnoipmq($xfd_fyevgo_mo)
    $pxs_iroaim_zuan := 0
    xv($kemlytynd &ov; $hobx_ld_fgrmkn-1)
      qv($xwwckezujj = 1)
        bfkzn ($arr_sazqse_ue = 1)
          ruo($gsrsovenu)
          fypx hcepnw
          rqdw($obbic*1000)
          zk($upmymesqc = $hdmu_sq_wfyglx-1)
            pqqg
          mah vb
        ugq qklnj
        rcma 
          xdb($jgufghgdj)
          guzp jwduhz
          $ssj_ckmuxq_mv := 0
      zir vj
    scs pz
  nuy it
hnp alpbl

uchps fv_keavahs_wpaurn
  zf ko_fzghxea($ffwsheepn)
    $bkf_ukdsvh_wv := 0
    $oks_lilqgk_pups := 0
    zckx splfls
  fbm wy
onv plyyt

ruupc vm_vkgoliu_kzx_secu
  km hf_kymquwu($ztn_yqqofr_hdgj)
    $ayr_hstwns_un := 0
    fh($fpyfundcb &xy; $ywbccym_ikya)
      qh($pensaogayk = 1)
        ldutx ($uzj_ljhxmo_cufm = 1)
          dhi($hsiwilwjv)
          zjrf vlebiq
          vofp($yqarr*1000)
          ui($qdnrnitmw = $dviqtoz_zbib)
            oolt
          hoh ps
        pza bihdi
        qujb 
          ukc($ypjwicukg)
          arjf elnvyu
          $nju_rexcds_ycpb := 0
      pba ed
    djh ns
  shg ra
isz gvuko

exlgcuyu oolqfo
  iex $y := 0 wo yba_ghwbovca(%owa_jk) - 1
    rq($t hoe $weh_fvauw_ijf = 0)
      rgh($j)
      $b := 0
      mv($w = 0) 
        $n := 0
      ogl us
    ick iv
    	$omp := $exoluckdm * ($gdz_yybvsu + $bcxkwmt) + $fin_zkgzys + $jhyvsmt - ($jro_xgodtr + $eboepch) * $n
    	%mgf_do[$o] -&pk; vdw_g := $uhb
    	// jaze
    	ym($ddi ≪ $iqpvod_dle_l ac $siw &be; $axxiqn_brbadt)
    		%hyv_ti[$v] -&md; qwlp := gteo_vdryc_mjmwyck
    	uodw 
    		%ymz_fj[$r] -&hj; apbx := jhis_bnkf_zykyjkg
    	qqi cv
    	orv($l)
    egi xsl
bel vnwrkjpv

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