Posted: 25th Nov 2020 4:11
nothing shows up searching "Scrollbox" so made a simple example with MouseWheel and/or Drag functionality using SetTextScissor() :
+ Code Snippet
// Project: Scrollbox 
// Created: 2020-11-20

// show all errors
SetErrorMode(2)

// set window properties
SetWindowTitle("Scrollbox Example")
SetWindowSize( 1024, 720, 0 )
SetWindowAllowResize( 1 ) // allow the user to resize the window

// set display properties
SetVirtualResolution( 1024, 720 ) // doesn't have to match the window
SetOrientationAllowed( 1, 1, 1, 1 ) // allow both portrait and landscape on mobile devices
SetSyncRate( 30, 0 ) // 30fps instead of 60 to save battery
SetScissor( 0,0,0,0 ) // use the maximum available screen space, no black borders
UseNewDefaultFonts( 1 ) // since version 2.0.22 we can use nicer default fonts

lorem$ = "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Non consectetur a erat nam. Tempus iaculis urna id volutpat. In hac habitasse platea dictumst. Euismod nisi porta lorem mollis aliquam ut porttitor leo a. At urna condimentum mattis pellentesque id nibh tortor id. Ut tellus elementum sagittis vitae et. Ultrices tincidunt arcu non sodales neque sodales ut. In pellentesque massa placerat duis ultricies lacus sed turpis tincidunt. Tellus in metus vulputate eu. Diam vel quam elementum pulvinar. Tellus orci ac auctor augue mauris augue neque. Sagittis nisl rhoncus mattis rhoncus." 

//next paragraph. CHR(10) = Line Feed
lorem$ = lorem$ + CHR(10) + CHR(10) + "Orci dapibus ultrices in iaculis. Aliquam malesuada bibendum arcu vitae elementum. Morbi non arcu risus quis varius quam quisque id diam. Curabitur gravida arcu ac tortor dignissim convallis aenean et. Mattis rhoncus urna neque viverra. Congue quisque egestas diam in arcu cursus. Magna eget est lorem ipsum dolor sit amet. Eget nullam non nisi est sit amet facilisis magna etiam. Facilisi morbi tempus iaculis urna id volutpat lacus. In vitae turpis massa sed elementum. Egestas sed tempus urna et pharetra pharetra massa massa ultricies. Leo duis ut diam quam nulla porttitor massa. At elementum eu facilisis sed odio morbi quis commodo odio. <end>"


ThisBox = Scrollbox(lorem$, 300,200,24,600.0,120.0 ) `FUNCTION SYNTAX: Scrollbox(ThisText$,X#,Y#,TextSize, BoxWidth#, BoxHeight#)

Back = CreateSprite(0)	:	SetSpriteSize(Back,600+8,120+8)	:	SetSpritePosition(Back,300-4,200-4) `only a visual to show pointer over scrollbox/active. 

do
	If GetTextHitTest( ThisBox, GetPointerX(), GetPointerY() ) 

		SetSpriteColor(Back,64,64,64,255)
		
		If GetRawTouchCount(1) = 1 `if Touch
			MWD# = (GetRawTouchCurrentY(1) - GetRawTouchLastY(1)) *0.1 `set your own sensitivity
		Else
			MWD# = -GetRawMouseWheelDelta()  `Else Wheel
			If MWD# <> 0.0 then MWD# = MWD#/ABS(MWD#) `same here. i just want -1/1
		Endif
		
		If MWD# <> 0.0 then SetTextY(ThisBox, GetTextY(ThisBox) - MWD#*GetTextSize(ThisBox))
		
		//keep top/bottom lines visible. we originally set the y position to 200 with a boxheight of 120
		If GetTextY(ThisBox) > 200 then SetTextY(ThisBox,200)
		If GetTextY(ThisBox) < 200 - GetTextTotalHeight( ThisBox ) + 120 then SetTextY(ThisBox, 200-GetTextTotalHeight( ThisBox )+120)
		
	Else
		SetSpriteColor(Back,0,0,0,255)		
	Endif

    Print( "Hover over/Touch Text to check for Scroll." + CHR(10)+  "MouseWheel/Drag to Scroll" )
    Sync()
loop

Function Scrollbox(ThisText$,OX#,OY#,TextSize#, BoxWidth#, BoxHeight#)
	ThisBox = CreateText(ThisText$)		:	SetTextPosition(ThisBox,OX#,OY#)
	SetTextSize(ThisBox,TextSize#)
	SetTextMaxWidth( ThisBox, BoxWidth# )
	SetTextScissor(ThisBox,OX#,OY#,OX#+BoxWidth#,OY#+BoxHeight#) `sets the Scrollbox area 
EndFunction ThisBox


lots of room to expand; add your own below?
Posted: 26th Nov 2020 5:21
Thanks for sharing this resource. As you know I'm looking for exactly this sort of function. Will give it a go.

Surprised this wasn't a default commands in AppGameKit
Posted: 1st Jan 2021 18:25
Hello on 27 november i made a discussion on steam asking for help you replied with this thread and told me if you need additional functionality or explanation, feel free to post in the thread there. Firstly i am so sorry that i am asking this late but i had so much assignments and corona and my father being hospitilized which led to me spending many hours catching up with my school, and this is the first break i got.

Anyway i am a bit confused about your code as instead of defining variables it uses things like # which i understand from research it defines object type, can you made a version without using characters like # and instead define variables i tried changing the code but i get errors as i want to put multiple text objects to that function
Also if you can implement it in a way that the function can take different text's, because what i want to do is have 1 sprite and each time i want to display something like how to play, or results i want to display them using same function, i also want to do this:
i am currently recording some text on an array and i want to display them when user clicks history, i will display first x elements on screen and when user clicks on arrows it changes like elements 2 to x+1 is shown, so basicly i want to use a very dinamic text, right now i can do all this exept displaying my next on sprite which is why i need your code.
Thank you so much in advance and sorry if i explained poorly i am very tired, i can explain again if you ask where to explain again.
Posted: 9th Jan 2021 2:29
kocakcem,

if you want to provide a simple example (which i understand will not work), i'd be happy to take a look and help fix.
Posted: 18th Jan 2021 18:44
Thank you for share it !! Very helpful !
Posted: 19th Feb 2021 1:48
Anyway i am a bit confused about your code as instead of defining variables it uses things like #


Variable1 is an integer
Variable2# is a float
Variable3$ is a string

This is equivalent to declaring them without having to declare them.

Variable1 as integer
Variable2 as float
Variable3 as string