Page 1 of 1
too long string to show in one line ?
Posted: Fri Nov 23, 2012 10:01 am
by Nubeat7
hallo, iwant to do a label, for the presetmanager, which dont write 2 lines when the string is too long, i would prefer that it shortens the string and keep it in one line i.e.
"dark arp syn..."
and not
"dark arp
synthecizer"
is there a way to do this?
and a maximum lenght of the string would be fancy too...
Thanks
Re: too long string to show in one line ?
Posted: Fri Nov 23, 2012 12:57 pm
by trogluddite
Yes, both the Ruby and primitive texts let you do this; you need to turn off word wrapping.
For priimitives, you use the format option "nowrap". For example, on the Text primitive, connect a string to the 'SF' input, and write "nowrap, left, centre" for one line text, left aligned, in the middle of the height.
For Ruby - you need to use the setFlags method for the formatString object - there's a list of the codes in the user guide (4096 is the right one for "nowrap" IIRC), e.g.
Code: Select all
@my_format = formatString.new
@my_format = setAlighment("left")
@my_format = setLineAlignment("top")
@my_format = setFlags(4096)
In Ruby there's load of extra flags that the Text prim' doesn't have - don't quite understand them all yet, but a quick experiment setting the number from an input value should soon find the most useful ones. Then you just add together the numbers of the ones you want to use.
Re: too long string to show in one line ?
Posted: Sat Nov 24, 2012 12:18 am
by Nubeat7
thanks trog, great it stays in one line now with the flag (4096) also when the label is higher... to shorten the string with "..." for the last characters i used this lines inside the code:
Code: Select all
s = @label[0...90]
l = @length
if l <= 3 then l = 3 end
if s.length >= l then s = @label[0,l-3] + "..." end
it shortens the link now like this when its longer the 14 character
"dark arp syn..."
i also found out that the max length for preset names are limited to 24 characters by the presetmanager anyway..
get this little gimmick for toolbox here:
viewtopic.php?f=3&t=953
Re: too long string to show in one line ?
Posted: Mon May 06, 2013 1:04 am
by RJHollins
Thanks NuBeat !
Very handy. Thanks Guys for a bit of the RUBY lesson
