Relative Item Positioning?


Author
Message
Marcel
Marcel
Expert (1.5K reputation)Expert (1.5K reputation)Expert (1.5K reputation)Expert (1.5K reputation)Expert (1.5K reputation)Expert (1.5K reputation)Expert (1.5K reputation)Expert (1.5K reputation)Expert (1.5K reputation)
Group: Forum Members
Posts: 9, Visits: 121
Hi,

I was wondering whether a method exists to position items relative to other items?

Failing that, what would be best practice to position items in one and two dimensions such that items are equidistant or spaced by a fixed amount? 

In the example below the gap between items increases with the length of the item. Is there a way to access the greatest value of the x coordinate and then just add a fixed value for the spacing? Or a general formula for converting the length of the item into px? 

<defaults>
/inputdevice = mouse
</defaults>

<values>
/currentX = 100
/yPosString = "300px"
/xPosString = ""
</values>

<list firstWord>
/items = ("Short", "Longer", "MuchLonger")
/ selectionmode = sequence
</list>

<list secondWord>
/items = ("Short", "Longer", "MuchLonger")
/selectionmode = sequence
</list>

<list thirdWord>
/items = ("thirdWord")
/selectionmode = sequence
</list>


<text partA>
/onprepare = [   values.xposstring = concat(values.currentx, "px")]
/items = ("<%list.firstWord.nextvalue%>")
/position = (values.xposstring, values.yposstring)
</text>

<text partB>
/onprepare = [   values.currentX += (15 * length(text.parta.currentitem)) ;
            values.xposstring = concat(values.currentX, "px")]
/items = ("<%list.secondWord.nextvalue%>")
/position = (values.xposstring, values.yposstring)
</text>

<text partC>
/onprepare = [   values.currentX += (15 * length(text.partb.currentitem)) ;
            values.xposstring = concat(values.currentX, "px")]
/items = ("<%list.thirdWord.nextvalue%>")
/position = (values.xposstring, values.yposstring)
</text>

<trial q1>
/stimulusframes = [1=partA, partB]
/validresponse = (partA, partB)
/ontrialend = [values.currentx = 100]
</trial>

<trial q2>
/stimulusframes = [1=partA, partB, partC]
/validresponse = (partA, partB, partC)
/ontrialend = [values.currentx = 100]
</trial>

<block test>
/ trials = [1-3=q1; 4-6=q2]
</block> 


Thanks


Marcel

Dave
Dave
Supreme Being (781K reputation)Supreme Being (781K reputation)Supreme Being (781K reputation)Supreme Being (781K reputation)Supreme Being (781K reputation)Supreme Being (781K reputation)Supreme Being (781K reputation)Supreme Being (781K reputation)Supreme Being (781K reputation)
Group: Administrators
Posts: 10K, Visits: 50K
Yes, you can position elements relative to other elements. First, you'll want to specify an appropriate /size for your stimulus elements. You can then use the elements' width, height, hposition and vposition properties to place other elements relative to each other via expressions in their respective /hposition and /vposition attributes.

For testing purposes, I would also recommend setting /txbgcolor to get a visual impression of the bounding rectangle and be able to see what's going on on-screen. You my also want to utilize the /hjustify and /vjustify attributes to change an items placement relative to its stimulus element's bounding rectangle.

Also, if you ultimately want to do position and size calculations based on a string's length(), you should use a fixed-width (i.e., monospace) font for consistent results.

GO

Merge Selected

Merge into selected topic...



Merge into merge target...



Merge into a specific topic ID...




Reading This Topic

Explore
Messages
Mentions
Search