1

Within my text field on LiveCode I would like two separate lines of text. It would be set out like this:

First line of sentence
Second line of sentence

How do I do this?

CoopDaddio
  • 577
  • 1
  • 5
  • 20

3 Answers3

0

If you enter text manually, you type the return key or the enter key to add a return character to a text field. You can also do this by means of a script.

Use cr to define returns in text fields. E.g. if you have one stack with one field, execute the following line to put two lines into the text field:

put "First line of sentence" & cr & "Second line of sentence" into field 1

You can include this line in a mouseUp handler in a button for instance.

Mark
  • 2,380
  • 11
  • 29
  • 49
  • 1
    Mark's answer is spot-on. Keep in mind that the end-of-line character within LiveCode is ASCII 10. RETURN, CR, and LINEFEED are all synonyms that stand for ASCII 10. – Devin Apr 28 '16 at 16:01
0

You can take this a step farther, and become more familiar with what LC calls "chunk expressions". Say you have a single sentence in a field. Consider this in the script of a button:

on mouseUp
  put return after word 3 of fld "yourField"
end mouseUp

Now try this:

on mouseUp
  put return & return after word 3 of fld "yourField"
end mouseUp
dunbarx
  • 756
  • 5
  • 4
0

I was wondering the same thing then kept tinkering and found the "recipe" almost certain there is a better way, but this was logically the best I could think of. Still learning the docs and couldn't find a todo list example.

on mouseUp
   put the text of field"NewItem" into NewItem
   put the text of field"GroceryList" into GroceryList
   set the text of field"GroceryList" to empty
   put GroceryList & return & NewItem into GroceryList
   set the text of field "GroceryList" to GroceryList
   set the text of field"NewItem" to empty
end mouseUp