Search guides and the APICtrl K
  1. API reference
  2. Native GUI

gfx/text_area.h

A text field of several lines.

#include <sonore/gfx/text_area.h>
On this page

Design notes

Why a second class

text_editor.h keeps to one line and says why: up and down between lines, a vertical scroll and a selection that spans lines make a different object, and one class pretending to be both does neither job well. This is the other object -- the notes a user keeps with a preset, a patch's description, a comment saved with a session.

Lines wrap where Font::wrapText wraps them, at the breaks Unicode's line breaking algorithm allows, and break where the text has a line break. The text is kept as UTF-32 for the reason TextEditor keeps it so: every caret operation is on characters. Line breaks are stored as LF whatever the clipboard or setText brought -- CR LF and a lone CR become one LF, and so do VT, FF, NEL and the line and paragraph separators -- so a caret never stands between the two halves of a Windows line ending, and every break a line can end at is one a triple click and Return agree on.

An input method's composition is shown and laid out as TextEditor's is (see text_editor.h): every path that lays lines out or places the caret reads the SHOWN text -- the value with the composition in it -- and every path that edits commits the composition first.

Types 1

class TextArea : public Widget, public TextInputTarget

An editable text field of several wrapped lines, where Return is a new line; TextEditor is the single-line one. See the file comment for why they are two classes and how line breaks are stored.

Text goes in and out as UTF-8 (setText, getText); every break comes back as LF. setText does not notify unless asked. With no Return to commit a value, onFocusLost is where a typed value is taken, and onTextChange fires on every keystroke. Message thread only.

↑↓ to move↵ to openEvery public name in the headers, and every guide