Scrollable TextBox2?

Hi! I am using TextBox2 to create a typed response. However, I want the participants to be able to write as much as they desire. Is there a good way to make only the textbox scrollable.

Note: I have seen a scrolling text using a rectangle to crop the bottom of the text that is being show. However, I have two stimuli on the bottom that can’t be covered. Any ideas?

Very much appreciated!!

1 Like

Hi There,

I think if you use textbox in builder in the current release it does this (scrollable textbox) so if you are trying to code something maybe go to builder then compile and editable textbox from there?


Hi Becca
Thank you so much for your reply! I was using the 2021 version but I downloaded the most recent version. I am not sure what feature I turn on to do this?! I don’t believe I see any explicit “scroll” feature on builder.

I think Becca may be referring to running online, I’m guessing you are running locally? I don’t think the :textbox: Textbox component can natively scroll when running locally, but it is achievable using code. I’ll have a crack at it myself now and get back to you with a solution.

What I did to get this to work is as follows:

  • Create an :aperture: Aperture component with the same size, position, units, shape, etc. as the :textbox: Textbox component

  • Create a :slider: Slider component with the following parameters in the Basic and Layout tabs:

  • Create a :code: Code component with this in the Each Frame tab:

if textbox.status == STARTED:
    # Update textbox text according to scrollbar
    textbox.contentBox.pos = textbox.pos + (0, textbox.contentBox.size[1] * -scrollbar.markerPos)
    textbox._needVertexUpdate = True
    # Disable automatic textbox drawing (but don't change its status)
    ogStatus = textbox.status
    textbox.status = ogStatus
    # Draw textbox manually with aperture enabled

You can replace any reference to textbox in the code shown above with whatever your textbox is called, and this should work - importantly, without obscuring any other stimuli behind the :aperture: Aperture component.

Thank you so much! I am going to test it out as I add in the stimuli! We are changing some things around so its been chaotic but thank you very much!