PDA

View Full Version : Trying to get a text input field to dynamically size to contents



dr_venture
July 23rd, 2013, 07:22
It is a field containing a skill description that may or may not fit on one line. I got the layout looking great, but I had to specify the width of the field, and now the longer text descriptions are just chopped off. The old layout had some convoluted means of building the skill layout from the right, then the Description field just filled in 1 or multiple lines depending on the length of the contents. Isn't there a setting for telling the field that it can resize itself if necessary?

Moon Wizard
July 23rd, 2013, 08:29
By default, stringcontrols are single line.

If width and/or height is not defined, then the string control will size itself horizontally and/or vertically according to the contents. This is best used for static stringcontrols, since text entry fields need to be always visible.

To enable multi-line mode for string controls, use the multilinespacing tag. Usually, you want to specify a width (or both horizontal anchors) and not specify a height when using multilinespacing, so that the control can will wrap the text correctly but resizes vertically to match content. The height of a control specified with multilinespacing is always at least one multiple of the multilinespacing value.

Regards,
JPG

dr_venture
July 23rd, 2013, 15:44
Neither of the above options seem to work, although this is not a "stringvontrol" (per se - I'm still unclear as to exactly what's what as far as controls and such go). Here's the code - any ideas?

<textlistitemvalue name="value">
<anchored>
<to>statlabel</to>
<position>left</position>
<offset>3</offset>
<size>
<width>311</width>
</size>
</anchored>
<script>
function onInit()
local vTitleText = window.value.getValue();
if vTitleText == "" then
window.number.enable(true);
window.number.setSourceValue(0);
window.dice.enable(true);
window.dice.setSourceValue({"1","d20"});
end
end
</script>
</textlistitemvalue>

Moon Wizard
July 23rd, 2013, 22:38
The "left" position value automatically sets the top and bottom anchors to match the "statlabel" control. Try using the "lefthigh" value for the position tag.

Regards,
JPG

dr_venture
July 24th, 2013, 17:05
Worked perfectly - thanks!