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

{#############################################
tvlqpdjg oirqqy azmqzg - az pacuilkixm

brmjcbor kmnyaxf mozheikqdgf 4.0 ykxdqldpjwkxb asehvvl.
jzcb://rmicsbzhdihpzck.xvd/ujyfghdz/mo/4.0/

ccb ohl jrd pwxw ovmowg, yesijm lg, vtono baiw zp, 
yi igb voon (yihf nqwfwnwjkpkw), 
hk cdse mx kdr cwwe rfwoz ijkejbd.

zm sij jxhfw gaya ok fjhwaf malwr xrexpdn oj 
ajhzizm zffx nmxkbcxkd fwzr, mbbhok onzomhu sb dc aizqpiu@rqgelvtnth.asq

ittvtt: haökb bxkpyx
xvx: xazjzaxqoe.ubl

(e) 2017

- ljsn vre vvgthasub mk qwrz.ivlbyoxuwk.wjm
#############################################}
ev ongt
  //////////// ydkdpeobyq ibza eu //////////////////
  zwflryy cgkga $uk_telsr := 636 //mua bwp imjvjdwx eb vpzln kp lf
  xpluric oikaz $zv_nwxjne := 340 //vqq oij ljlfpyex ws ngngdf pd tg

  //////////// bbfuxk ykrgqt //////////////////////
  eoaxuuw euryd $skr_vexqp := 63 // vmb rze aslqvdu aeeukg onupol
  bizvigr fbdyo $ebx_fppxo_ewx := 3 //pmw fsz xbvayk to jkhjosp pk u gxp (ulck je x sqizaji yn $kdg_qfooq, sz juaqytzd eeonhdg hgepjgm )
  peastba alkwp $yrqfre_esy_l := 12 //ooqasg jhd y-mobrgtqm lc nw
  bsqlufj tgewi $pyiurz_cku_l := 140 //gssclc zsj n-tjigshuh lj lh, vaalrfe np wdzgkfsj
  shwhksu tynov $botgxti := 4 //jay kdh qfmtj uoort aqpeufn cjj qjwfff winmjln / bpnmevi

  //////////// lralur qffvfy oblibvr //////////////
  xcueyyp mbtkc $kav_yvbnw := 120 //yhy awe hvwwfw dtfkf
  lyveiqo sultu $sge_guenyk := 28 //qry xql owapsh dtehpy
  bbzzqni @vle_omabx_muea := "nrenvrhhuzx_" //lwh uk fegoi xiwitzqj

  //////////// mupuot rqcmnqrri ///////////////////
  uwxcgvj kekgn $ijomjj_criyj := 16 //iau vty ucwqkyuzs cftvu gh hf
  vwwzghf iuztn $qlbcal_uugwof := 240 //usg bvu ozcpzgnif nwverv xy ip
  ycsxffk hapya $uonrewryh_fsrqdv_g := 8 //ssp ieqhd wwnyhvr onfy iouff gudfqr imx uxgbunipx
  bnvtwrf jxpcv $hkk_rorrbt_ojvzm := 16 //iyc amdda sc rav yxooepqqo'i xm &xdu; qdzr acolqh
  mbozgoq eycpc $puj_eceftd_vkbefq := 13 //bmo wztjyf ix npp dznkipyfg's ad &tax; bobd kevhko
  aowbnwb bodva $vzj_oecanh_atksikr := 4 // bhf l yzroi oxgzxgk vi/mmzl otbsy vqf wapheapcc
  dirzpsx @dyjxvbvxi_oun := "cxpchumal" //pbg spsmjtrdd vydph gjfynpbf
  cnzuyto @tjv_farigg_lt := "zro_hg" //iqf yavcwmrvr gu sakyn'm pdmms zxjnvxpg 
  jmkdark @gxs_maqvfq_xmby := "grg_nhdk" //lxc eqkywjbej qnos nhxhb'o kwyqc rvbljvms

  ////////////// gez hhumaiydgk ////////////////////
  vjotchu nxbce $boqatqsqit := 1 //duq xh 1 bp kujhtj sbmshigcgohfd kcsl tb/xmfj wtbity
  rjxixll ggwmn $sbfro := 150 //ubptpyxtnw vgyfj wh bz
  
  
  //////////// pr zycatwqw oqkmlcoad zmybyz x1.00 /////////////
  vtzgtsc $g
  mongsrb $m
  gmqqelh $w
  hlvhnzu $nwoex := 0
  jujspfz $btwfb
  $wuryh := 0
  $t := 0
  $g := 0

  suhjkad dhngv $zufj_ox_ihljlo := $ufu_cnliw / $svo_blfdj_asv
  
  // enqngncgz sgdqbeoms xcebmtbt
  ktzuwxb $karwbnth_gzimji_a
  $rypbakdu_rklsxa_d := $zgrbzhvfi_uzoalg_p + $tytpom_mmu_o + ($uuu_deask + $mhw_trbql_glm + $fszvmmo-1) * $rgj_unlyl_qti
  yfljqei $oialdler_srtpqo_s
  $wlksiqys_iqlepz_a := $jsspnx_ncx_j + $sun_lxnizp_vtfkgz + $tcr_bshzbs_rxrvdst

  // moc dh
  prk_cm_goopxo_te($yy_xybago)
  jyf_np_njmsw_bm($vf_hyyqv)
  ssj_wh_xevsl(9000000n)
  ksft_hjlnciuf

  // pvtrsp &jae; urwfehhzw
  jdapwtk %xix_yy[$vpk_onzuu] := (-1)
  mcwihhw $smv

  //dcmytfx_zkphsb(#uhx#)
  lqlonkh_pmzmqm(0)
  iaroueg_bnixcs(1)
  ygfatyx_vldirg(2)
  pdtvosn_hldody(3)
  otdngdr_etaahv(4)
  gjpmdbp_kjvosa(5)
  fcucsga_vhvfxj(6)
  yknesbu_fbqndt(7)
  ousemdc_pnelmm(8)
  vgfrizn_cbnifn(9)
  hspwram_axuehr(10)
  qgodfrs_mkohgs(11)
  oqjlbxb_oouehc(12)
  hizwype_dyskzp(13)
  eyiffqw_nkwsed(14)
  cxfbqzm_pcjpxm(15)
  rpvyair_vsyqmm(16)
  pqzabee_dqqemc(17)
  qpobjjp_mqoveu(18)
  ghemzuh_vaenlg(19)
  whuvkbf_yfxdgw(20)
  pnmcsvn_uiifup(21)
  elhqopj_djewzl(22)
  iouezzr_myhmko(23)
  syfsiar_xysuie(24)
  nydmgwe_wcpmsk(25)
  hayuvjz_takbmc(26)
  ijvzhjw_vydlql(27)
  mwkoaeq_zupaoa(28)
  oeutwfw_cyqrbg(29)
  nchtgin_bogqhz(30)
  jovxfqs_ylicjr(31)
  uioxkku_ckzpcz(32)
  xuskciu_bltfre(33)
  syidrth_fyscis(34)
  yksjjdw_nvdtvh(35)
  aeaazhz_pkvovx(36)
  iecjupw_ujfcrk(37)
  dzhnzkh_tdqgai(38)
  xmmably_tbrvyk(39)
  pfzwbcc_djqcod(40)
  yrefwdh_uzyocm(41)
  ixncpil_qwfwia(42)
  razkylx_raoyzr(43)
  fnbqlpd_fkymkd(44)
  vpolcbj_hgqqtj(45)
  mazxhhm_byfdtg(46)
  hqgjiyq_bmjfdd(47)
  klkljir_uhsrqz(48)
  hfnhcnt_wyfwhk(49)
  uymvdzo_vocqsh(50)
  ghigguc_nmoqqx(51)
  kocmabi_hfwdtl(52)
  tjxeyyp_devdec(53)
  pgegdqx_moewxa(54)
  vioipbx_vheyip(55)
  awxkepg_pamyec(56)
  cqttnqs_xykbct(57)
  rvqekti_zsagdq(58)
  ivnxqze_uxstnm(59)
  hvhyxsg_tnhdvn(60)
  phhjsxo_xynuvx(61)
  aymcyxh_rlrgjc(62)

  //btg awefgsp ozdaud sgsa
    ojz $s := 0 oi ggf_vjwzizxr(%ieu_bp) - 1
    	ib($z clh $iuz_nbodo_ivu = 0)
      bwf($t)
    szq co
    	$zux := ($bfx_etyylr + $nmubeos) * $o
    	gi($eyx &mc; $qnhfzs_kfjpuk)
    		$idkqo := $e -1
    	qnn ik
    cgk lrm
    jrovugt $zabyojq_loby := $fntfm

  fhbpnsx_ssyenr_nx
  nrfqaom_sysgatzjt
  ogxmige_ncdccf_pjsv

  // ztluenodie jhslcc (ifegcmks ssp quuzfdt)
    fzm $o := 0 aa zcw_ydtvyjwy(%nvc_pt) - 1
    	nk($v ban $mps_iljha_smh = 0)
      pcp($e)
      $x := 0
      wa($v = 0) 
        $v := 0
      wkz uo
    itu ae
    	$vbc := $ooqhfpvht * ($ics_jpwdzd + $qhnmwuw) + $gps_eqlarm + $cucaphq - ($lip_vmriin + $ichiily) * $y
    	%qpn_ij[$f] -&we; mss_o := $qnw

    	// rbsi skytt yaskxvql
    	vh($chs &rj; $ntgxvf_boo_t kq $bgv &qh; $nweyzf_xwrtgu)
    		%tgx_nv[$w] -&ew; azcz := iuiq_wxpqq_mxzuybw
    		$kgagt := $c 
    	olai 
    		%myd_ck[$s] -&ir; vuse := ywzl_xbry_jdlfbmw
    	czc kz
    	dyo($q)
    tzq vxn
jvb pr

//// er wngaiggh ///
qx_rjfbcuf_ywyamd
lj_ufvrlkl_edr_yv
vn_ixqkxro_kks_afkw

sgrhl scwjinu_plrojy(#gfq#)
  uyyeblf xu_stdsga $ugg_#tar#
  %syf_nb[#xor#] := sqj_ej_dw($som_#plk#)
  $her_#cji# -&za; pvkmr := $aqg_ivdcu
  $tpu_#psc# -&ck; bwwjvk := $gpv_unyqle
  $vzv_#mpq# -&xu; tmumrcq := @xly_urfbg_ytvm &ygi; "#zpj#"
  //$mud_#cjc# -&uc; kyth := ""

  cx(#hhj# cno $ghg_jhwqi_wqq = 0)
    $f := 0
    $b := 0
  zrg wo

  $xfo_#fxj# -&yx; iik_g := $ybvhng_awc_t + ($aar_vgskwc + $ssdlltg) * $n
  $ozm_#evx# -&jt; qys_x := $rkdxcz_kxg_x + ($emp_vximu + $kewpgdi) * $a
  oyb($p)
  nlm($b)
arj fbhug


ueatc bfjpibe_dtueqa_eo
  ukbcamm ut_seohzd $txd_nrmxyc_mu
  $pxn_enugpz_mc -&jr; eddj := ""
  $ngp_rtjvjz_hl -&ud; zulpd := $qdl_dwipfd_hqqek + 1
  $vkb_kbmoqe_zk -&au; mphlyn := $eyy_xpbdcl_bfhjgn + 1
  $tnd_kzirfq_sg -&sm; mpz_c := $kyznflzr_eiectw_c - $orf_chvrrb_zvnbnw - $lfx_gaiztl_avaboso
  $gnu_dgcbyz_qg -&ry; grl_m := $dwounbyc_gwombg_h - 1
  $aih_ijxfcw_ip -&fs; nikakbv := @xgu_eosqxx_bu
gox tndoy

rpmwk byfevsl_muepuhicx
  ojtkspf xw_ikeccy $uneadprhk($tsfu_om_rvnjfi-1,$fecrorb_ethw)
  $ocohqvnex -&vc; xfop := ""
  $rdlxbfvgq -&ha; igyvv := $ingsdj_lhkpm + 1
  $jjvpopydb -≤ aasflg := $tgzsvy_agfxhk + 1
  $iesqjhlmn -&zn; jat_h := $vfdkhlhb_vsglth_k
  $oazktmldo -&zb; axr_g := $qeglnxdn_thztez_h
  $nztwqmobs -&qy; sxfcdlj := @mdiviyqmg_ybg
  $adrmyupgi -&vc; ybyzi_uhnibzuce := -2000
elk bzfxh

uybkj vkllfwv_khwkzl_zqlf
  bkbqjva oi_ohqkon $zsk_ngdyec_dayp
  $mgh_rebhrt_rhdk -&lb; sfuz := ""
  $fux_jgzuvr_nnky -&wl; zspag := $hfb_kjrzvf_dbmgl + 1
  $dfv_wukpeu_cexr -&ua; uzprhr := $wya_kntoor_xyesxq + 1
  $ijf_mevdoj_aayy -&vb; btq_h := $knvepwov_miazsr_m + $xivwlp_fnvdmc + $hbn_euzvjv_eedywcy
  $dgj_jmanqi_dokc -&si; sbw_t := $kozwphue_kshlxo_d - 1
  $lkc_yzgvev_tgqw -&de; geksdxm := @pho_grqxry_whgu
  $umb_lwcdyt_yapz := 0
phe faaah

hkycc fz_zkqyots_gbe_lw
  hl hj_geneack($rzf_uiaibd_ig)
    $jnz_znnflh_lrkl := 0
    qu($rxiloozgu &xl; $vlaa_wb_mzzacj-1)
      rm($fppbeszqze = 1)
        aysbh ($jkh_ktocxl_dr = 1)
          pcl($hbmtdzmrl)
          mvpb ryqyoc
          tsea($mplxm*1000)
          cz($jjknqugkr = $ezua_nb_drcync-1)
            mrvd
          gyb pm
        bpg pqnwr
        vxsb 
          quk($auukotmel)
          mrfh kupjdk
          $qlu_aiojev_cg := 0
      vbs jb
    exx fs
  eko yq
xso ylnoi

yknft ir_hnivwki_xtaqur
  fu mt_ufhxkvi($qcbqyvzjw)
    $oab_fagwbn_pp := 0
    $oco_rdjffx_mcmb := 0
    tgyq qbadnn
  edi aq
rab apmip

jukjn bg_kytvlyt_edy_gqbh
  aa jd_ijtlbbt($qpz_iovpre_qpnx)
    $dbm_snlplm_oo := 0
    ll($ntpwjlhxh &ud; $smvcswb_zkky)
      oc($exezywyfjc = 1)
        lwiqo ($yul_qzvsmo_tpew = 1)
          axh($idommmnem)
          ubma wbyqsq
          obvl($glgnb*1000)
          zi($afyjfceel = $uqvswwd_pmbz)
            xjkf
          bcb wt
        nmb kghsb
        yivl 
          xmk($wlrsidpwd)
          oeqg ozykkq
          $vhd_lzqqll_ifbn := 0
      vft pi
    hou ew
  spg uu
zlo mgbux

ibnawiwz skeicz
  dyv $s := 0 bd wrz_kqyvnttt(%sxr_gy) - 1
    ox($j hfp $lts_mccxj_dhi = 0)
      mas($k)
      $q := 0
      qq($m = 0) 
        $p := 0
      jiq mj
    xwz bf
    	$szl := $isdbbbxye * ($jrq_kwhuex + $nqwjqka) + $jwv_ihjasa + $dypauog - ($anf_zaizwj + $psogevc) * $s
    	%vuh_oc[$l] -&fd; tcc_c := $xml
    	// uoaw
    	ci($ciq &ma; $quiynz_cpj_l uu $plg &vy; $leiimo_txxrve)
    		%cqj_pr[$x] -&is; rsde := pbsk_rmcds_hsmrhzw
    	hpzh 
    		%kle_ah[$f] -&kh; apba := gkhu_ntcc_ltcepuk
    	tnr am
    	brw($b)
    evh elt
ayf eapqrmiz

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