Locating text input

Hi,
I was trying to design a test in which participants are needed to write a text. My problem is I want to locate that text (regardless of its length and number of words) in the right half of the screen. The only thing I know is that it is possible to specify text position (x,y) in builder, however, it is related to the centre of the text. What I need is restricting that text into to a specific rectangle (e.g. right half of the screen.)
I will be really thankful if you can help.

Many thanks

Hi @Kaveh_Heshmati, this can be done using the ShapeStim contains method. Create rectangle polygon components in Builder that occupy the left and right side of the screen. You can make them the same color as the background, or give them no fill color. Then, in a code component, check whether the text component position falls within the polygons. E.g.,

if rightPolygon.contains(text.pos):
    print("Text is in the right polygon")
if leftPolygon.contains(text.pos):
    print("Text is in the leftpolygon")


1 Like

Many thanks @dvbridges
Much Appreciated.

Hi @dvbridges,
As you said, we can check whether the text component is inside the polygon or not using “polygon.contains(text.pos)” command, which is linked to the text position’s center that is assigned in text component (e.g. (0.5,0)).
Is it possible to determine the text position and not just check it? For instance, if we need to put the text just inside the right polygon, what can we do?
In this case, should we leave the position window in text component empty?
I appreciate your help.

Many thanks

You can set the wrap width of the stimulus as well. So if in norm coordinates, you set the x position to be 0.5 and the wrap width to be 1.0, then the text would be constrained to be in the right half of the screen (which has a total width of 2.0).

Hi @Michael
Thanks a lot. It works.
But I thought there should be a command like inserting text box in which we would be able to locate that box.
Thank you very much for your reply.