# ListNode
Class Inherits TextNode
## About
`ListNode` represents an ordered list, an unordered list, or a checklist in one editable node. Each list item can wrap and can contain explicit continuation lines.
## Enumerations
| Name | Value | Description |
| --- | :---: | --- |
| Types | Unordered <br > Ordered <br > Checklist | (None) |
## Methods
| Name | Parameters | Return Type | Description |
| --- | :---: | :---: | --- |
| ActionItem | index As Integer | ToolbarItem | Returns the contextual toolbar item at the specified index. |
| Constructor | value As String = "" <br> type As Types = Types.Unordered | (None) | Creates a new list node instance initialized from the supplied values. |
| Duplicate | (None) | Node | Returns an independent copy of this node and its configurable state. |
| EditingCaretFrame | position As Integer | Rect | Returns the document bounds of the caret at the specified text position. |
| EditingDrawOverlay | g As Graphics <br> selectionStart As Integer <br> selectionLength As Integer <br> caretPosition As Integer <br> caretVisible As Boolean | (None) | Draws the selection and caret overlay for the active editable content. |
| EditingHandleKey | key As String <br> shiftKey As Boolean <br> menuShortcutKey As Boolean <br> ByRef selectionStart As Integer <br> ByRef selectionLength As Integer <br> ByRef caretPosition As Integer <br> style As TextStyle | (None) | Handles a key press and updates the supplied selection and caret positions. |
| EditingHandlesKey | key As String <br> shiftKey As Boolean <br> menuShortcutKey As Boolean | Boolean | Returns whether the editable content handles the specified key combination. |
| EditingHitIndex | x As Double <br> y As Double | Integer | Returns the nearest text insertion index for the specified document coordinates. |
| EditingInsertText | position As Integer <br> value As String <br> style As TextStyle | (None) | Inserts styled text at the specified position. |
| EditingRemoveText | start As Integer <br> length As Integer | (None) | Removes the specified range from the active editable content. |
| EditingRestoreState | state As Variant | (None) | Restores a previously captured editing state. |
| EditingState | (None) | Variant | Returns a snapshot that can restore the current editing state. |
| FromHTML | element As GraffitiProEditor.HTMLSupport.HTMLElement | Boolean | Imports supported content and formatting from an HTML element and returns whether it succeeded. |
| HandlePress | x As Double <br> y As Double | Boolean | Toggles a checklist item when its checkbox is pressed and returns whether the press was handled. |
| HTMLTags | (None) | String | Returns the HTML tag names supported by this node type. |
| InspectorSections | (None) | InspectorSection | Returns the user-editable list properties exposed by the inspector. |
| ItemChecked | index As Integer | Boolean | Returns whether the checklist item at the specified zero-based index is checked. |
| ItemChecked | index As Integer <br> Assigns value As Boolean | (None) | Sets whether the checklist item at the specified zero-based index is checked. |
| LastActionIndex | (None) | Integer | Returns the last zero-based action index supplied by this node, or -1 when there are no actions. |
| LocalizeToolbarItem | strings As GraffitiProEditor.Editor | (None) | Sets this node type's toolbar item text from the supplied editor's localization properties. The editor calls it when the type is registered, when the editor opens, and when a locale pack is applied to the editor. A custom node type can override it to localize its own toolbar item. |
| PerformAction | index As Integer <br> selectedItem As DesktopMenuItem | (None) | Handles the contextual toolbar action at the specified index. |
| PerformToolbarAction | editor As Editor <br> selectedItem As DesktopMenuItem | (None) | Handles activation of this node type's main-toolbar item. |
| PlainText | (None) | String | Returns the node's readable content as plain text. |
| PreferredHeight | g As Graphics <br> availableWidth As Double | Double | Returns the preferred node height for the available width. |
| Render | g As Graphics <br> bounds As Rect <br> selected As Boolean | (None) | Draws the node within the supplied document bounds. |
| ToHTML | (None) | String | Returns an HTML representation of this content. |
| ToMarkdown | (None) | String | Returns a Markdown representation of this content. |
| TranslateLayout | offsetX As Double <br> offsetY As Double | (None) | Offsets this node and its cached descendant layout by the supplied distances. |
| TypeName | (None) | String | Returns the display name for this node type. |
## Properties
| Name | Type | Default Value | Description |
| --- | :---: | :---: | --- |
| Type | Types | (None) | Gets or sets this list node's configured type. |
## Notes
List structure and continuation lines are stored in one editable node.
### Checklists
A checklist draws a checkbox for each item instead of a bullet. Clicking a box toggles the item, including while the list is being edited, and `ItemChecked` reads or sets an item by its zero-based index. A checked state stays with its item's text when items are split, joined, or removed.
HTML export adds the `checklist` class and a disabled checkbox input at the start of each item. HTML import makes a list a checklist when any item starts with a checkbox input. Markdown uses GitHub task-list items: `- [ ]` and `- [x]`.
Checkbox images are drawn once per state, size, and display scale and shared by every checklist. Vector PDF output draws the checkboxes as shapes so they stay vector graphics.
### Editing and Nesting
Return begins a new list item. Shift-Return inserts a line break within the current item. Tab and Shift-Tab adjust the nesting level where applicable. Character formatting applies to item content while list markers retain the list's base marker presentation.
### JSON Values
The list type is stored in `content.listType` as `0` Unordered, `1` Ordered, or `2` Checklist. `content.listLevels` is an integer array containing the nesting level associated with the editable list content. `content.listChecked` is a Boolean array of checklist item states, written only when at least one item is checked. Text, styles, and embedded content use the `TextSnapshot` JSON format.
## Examples
Register a list prototype before inserting or importing lists.
### Checklist
```xojo
Var tasks As New GraffitiProEditor.ListNode("Draft" + Chr(10) + "Review" + Chr(10) + "Publish", GraffitiProEditor.ListNode.Types.Checklist)
tasks.ItemChecked(0) = True
Editor.AddNode(tasks)
```
### Ordered List
```xojo
Editor.AddNode(New GraffitiProEditor.ListNode("First item", GraffitiProEditor.ListNode.Types.Ordered))
```