How do I use hierarchical list support?

LiveCode now has support for hierarchical lists in fields. These are controlled with the listStyle, listDepth and listIndent paragraph-level properties.

The sample stack

The sample stack

Create a new stack , add a field to it and name the field "list". Add some text to the field which can be styled into lists.

In this example I have generated some Lorem Ipsum text and separated it into individual lines.

The listStyle property

The listStyle property

The listStyle property specifies what type of list style is to be used for a line of text. Setting the listStyle of a line, or number of lines in a field sets the bullet point for that line, or lines.

set the listStyle of line 1 to - 1 of field "list" to "disc"

Setting different listStyles in a field

Setting different listStyles in a field

You can set multiple list styles within a single field.

For example

set the listStyle of line 1 to 3 of field "list" to "disc"

set the listStyle of line 4 to 12 of field "list" to "decimal"

set the listStyle of line 13 of field "list" to empty

set the listStyle of line 14 of field "list" to "disc"

set the listStyle of line 15 to 17 of field "list" to "decimal"

set the listStyle of line 18 to 25 of field "list" to "lower latin"

Setting the listDepth

Setting the listDepth

The listDepth property of a line in a field specifies the depth of the line in a list, this allows you to indent individual lines different amounts, creating hierarchical lists and displaying information clearly.

set the listDepth of line 1 to 3 of field "list" to 1

set the listDepth of line 4 to 12 of field "list" to 2

set the listDepth of line 14 of field "list" to 1

set the listDepth of line 15 to 17 of field "list" to 2

set the listDepth of line 18 to 25 of field "list" to 3

Setting the listIndent

Setting the listIndent

Changing the listIndent property of a field allows you to specify the size of the margins used when indenting lists. This property can be set on a field, line of a field, or range of lines in a field.

In this example I am changing the listIndent property of all the lines in the field  to the same value.

set the listIndent of line 1 to -1 of field "list" to 50

Setting the listIndent of individual lines

Setting the listIndent of individual lines

You can set different listIndent values on different lines, allowing you greater control over the display of lists.

set the listIndent of line 1 to 3 of field "list" to 20

set the listIndent of line 4 to 12 of field "list" to 15

set the listIndent of line 14 of field "list" to 20

set the listIndent of line 15 to 17 of field "list" to 15

set the listIndent of line 18 to 25 of field "list" to 30

5 Comments

George R. Kenney

Is there a way to create an outline format with the new
hierarchical list properties such that the list would be something on the order of 1.1 1.2 1.3 or 2.a 2.b 2.3
so that a document could be outlined and the inclusion of a new paragarph or line at any point in the document would
automatically update the outline list.
Thank you

Hanson Schmidt-Cornelius

Hi George,

LiveCode hierarchical list support does not currently provide the kind of ordering you describe.

Kind Regards,

Hanson

grahame prestage

how can I add to a list from the contents of a text field input by user?

prestage

how can i add to a list from code

Hanson Schmidt-Cornelius

Hi Grahame,

lines in a list are handled just like any other content in a field. You should be able to insert text with syntax similar to the following one for user input:

put return & field "userInput" after line XXX of field "list"

or from code:

put return & "This is my new line" after line XXX of field "list"

where XXX is the line after which the content is to be inserted. We use "return" in the beginning to ensure that the text is not added to line XXX but is placed on a new line after line XXX.

Kind Regards,

Hanson

Add your comment

E-Mail me when someone replies to this comment