Drawing only parts of text

I have an object that I made called a ListBox, which stores a table of strings and displays them in a rectangle one after the other (one per line) If the user swipes up or down inside the ListBox, all of the texts displayed inside move up or down accordingly. This part works just fine, its just that nothing stops the text from displaying once it goes partway outside of the rectangle. Once a text completely leaves the rectangle, it ceases to be drawn until it reenters the rectangle. My issue is dealing with the text that is partly in and partly out of the rectangle. Does anyone have any suggestions? If possible, I’d like to avoid the following 2 things:

  1. Not drawing the text when any part of the text in is the bounding rectangle
    2)Adding another shape around the edges of the ListBox, so it hides the text that is not inside the rectangle

If I have to, I’ll resort to one of the two above methods, but I wanted to see if anybody had come up with anyway to only draw the top half of a text, if that makes sense.

The only solution i can think of is 2), sorry

look in the reference for clip(). Its pretty much exactly what you are looking for. :slight_smile:

Thanks @Jordan! the clip function was exactly what I was looking for! It made my code much simpler. I had come up with another method of doing practically the same thing, but it took up over 20 lines of code. With the clip function, I was able to replace all that code with just one line

Happy to help :slight_smile: