Ahhhhhhhhhhhhhhhhhhhhh!!! Help me! I'm slowly going mad. I'm trying to sort out line 35-ish. How do you translate the mouseY() into the value? Ahhh!! Banana crayon! I'm going insane!
Strict Type TVScroll Field x , y , w , h Field swp# ' How much percentage dose the scroll bar take up Field svp# ' Scroll bars percantage value Field spi# = 1 ' Percentage increase Field totr# ' Total range Field mouseHitY# Field mouseHitSPV# Field view_x,view_y,view_w,view_h,viewPortEnabled=0 Method Render() Local height=((swp/100.0)*(h)) SetColor 100, 100, 100 DrawRect x , y , w , h+height SetColor 255 , 255 , 255 Local v=(((svp/100.0) * h)) DrawRect x,y+v,w,height If MouseDown(1) If mousehit1 And mouseHitY=0 And mousein(x,y+v,w,height) mouseHitY=MouseY() mouseHitSPV=svp EndIf Else mouseHitY=0 mouseHitSPV=0 EndIf If mouseHitY And MouseDown(1) mouseHitSPV = MouseY()-mouseHitY svp=mouseHitSPV If svp < 0 Then svp=0 If svp > 100 Then svp=100 EndIf End Method Method MoveUp() svp:+ spi If svp > 100 Then svp = 100 ' Simple range checks End Method Method MoveDown() svp:- spi If svp < 0 Then svp = 0 End Method Method GetRangeValue#() Return (svp / 100.0) * totr ' Get the percentage value of a max range End Method Method SetRange(_range#) totr = _range End Method Method enableViewPort() SetViewport view_x,view_y,view_w,view_h End Method Method disableViewPort() SetViewport 0,0,GraphicsWidth(),GraphicsHeight() End Method Method setScrollBarViewPort(x1,y1,w1,h1) view_x=x1 view_y=y1 view_w=w1 view_h=h1 End Method Method setCoords(x1,y1,w1,h1, swp1,totr1) x=x1;y=y1;w=w1;h=h1;totr=totr1 swp=swp1 If swp1=-1 swp=(100.0/totr) EndIf End Method Method mouseIn(x1,y1,w1,h1) Local mx=MouseX() Local my=MouseY() If mx>x1 And mx<x1+w1 If my>y1 And my<y1+h1 Return True EndIf EndIf Return False End Method End Type Graphics 800 , 600 Global mousehit1=0 Global sv:TVScroll = New TVScroll sv.setCoords(520,10,14,250,15,500) sv.setScrollBarViewPort(10,10,520,250) While Not KeyDown(KEY_ESCAPE) Cls mousehit1=MouseHit(1) sv.render() sv.enableViewPort() DrawText "Value: "+sv.GetRangeValue(), 10, 10-sv.GetRangeValue() DrawText "MouseHitY: "+sv.mouseHitY,10,20-sv.GetRangeValue() DrawText "MouseHitSPV: "+sv.mouseHitSPV,10,40-sv.GetRangeValue() DrawText "Calc: "+sv.svp,10,60-sv.GetRangeValue() For Local i=1 To 20 DrawText "Information here",10,(60+(20*i))-sv.GetRangeValue() Next sv.disableViewPort() DrawText "HELLO",400,400 If KeyDown(KEY_DOWN) Then sv.MoveUp() If KeyDown(KEY_UP) Then sv.MoveDown() Flip Wend