PDA

View Full Version : multi-line label?


bhnh
03-11-2008, 03:23 PM
Is it possible to have more than one line in a single label? I've tried "\r" and "\n" without any luck. Many thanks.

Jon-Huhn
03-11-2008, 03:46 PM
I think "\n" does work, but you need to had extra height to your label using the height:someHeight parameter otherwise it will cut off your additional lines.

bhnh
03-11-2008, 03:52 PM
Hi, J_H. I know that height can be applied to editText, but to my knowledge alignment is a label's only property.

edit: I stand corrected. I tried height:28 and it worked a treat. Thanks!

PEN
03-11-2008, 06:45 PM
Ya know I never tried that. Very cool.

bhnh
03-11-2008, 07:01 PM
It is kinda neat, isn't it? The multilines seem to default as a flush-left, but tapping the spacebar can let you at least approximate centered text.

ZeBoxx2
03-12-2008, 12:35 AM
It is kinda neat, isn't it? The multilines seem to default as a flush-left, but tapping the spacebar can let you at least approximate centered text.

If you want to center text, you can try a function such as the following.

fn centerString str width = (
local spaceWidth = (getTextExtent " ").x
local strWidth = (getTextExtent str).x
local numSpaces = ((width / 2.0) - (strWidth / 2.0)) / spaceWidth
local spaces = ""
for i = 1 to numSpaces do ( append spaces " " )
spaces + str
)


You'd have to split things up into multiple lines yourself before checking whether each line would need to be pre-padded, of course.

Quick example code for single-line use:

rollout test "test" (
-- bitmap is just there to frame the label
bitmap bmp_dummy "" width:102 fieldwidth:102 height:18 pos:[7,7]
label lbl_test "" width:100 height:16 pos:[8,8]
)
createDialog test

-- set a text the usual way (aligned left)
test.lbl_test.text = "Hello World"

-- set as centered
test.lbl_test.text = centerString "Hello World" 100 -- 100 = label width

bhnh
03-12-2008, 03:29 PM
Sweet, ZB. :thumbsup:

Kramsurfer
03-12-2008, 04:06 PM
It's funny what you never try sometimes... this is new to me too....
I guess there's no more dialogs defined like this!... ha ha...

....
label LB01 "The Move Vert Functions of Vert to Mesh can be found directly below" Align:#center
label LB02 "the Vert To Mesh script in the Customize User Interface dialog." Align:#center
label LB03 "" Align:#left
label LB04 "\" Vert to Mesh - Move Verts \" - Moves selected Verts to Target Mesh" Align:#left
label LB05 "\" Vert to Mesh - Minus Soft Select\" - Subtracts Spinner Amount from falloff" Align:#left
label LB06 "\" Vert to Mesh - Plus Soft Select\" - Adds Spinner Amount to falloff" Align:#left
label LB07 "\" Vert to Mesh - Toggle Mesh\" - Toggles between Selected and Target Mesh" Align:#left
label LB08 "\" Vert to Mesh - Toggle Soft Select\" - Toggles Soft Select checkbox" Align:#left
label LB09 "\" Vert to Mesh - Toggle Z Only\" - Toggles Z Only function" Align:#left
label LB10 "" Align:#left
....

That's a neat function too Zeboxx2...

Thanks!

bhnh
03-12-2008, 06:41 PM
Yeah, Keith, that's pretty much what I was facing before I posted. :scream:

Kramsurfer
03-12-2008, 07:45 PM
It falls right in line with the Messagebox string display...

Messagebox " Hi There\nThis is a whole Line\n\nWOW\n WOW"

CGTalk Moderation
03-12-2008, 07:45 PM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.