Skip to content
FutureBlitz

    Install

    Import std.term.views

    TextInput

    std.term.views

    class

    Public Class TextInput

    A line of text to type in, edited as a shell's line is (see LineEditor's Handle), which Draw shows in a Region's first row, scrolled sideways to keep its cursor in view. A Placeholder shows while it's empty, and a Mask, like "•", in place of each character, as for a password.

    Examples

    Local input = TextInput()
    input.HandleKey(KeyEvent('h'))
    input.HandleKey(KeyEvent('i'))
    input.HandleKey(KeyEvent(KeyCode.BACKSPACE))
    Expect(input.Text == "h" && input.Cursor == 1)

    std/term/views.fb, line 176

    • Public Field Placeholder: String field #

      What shows while it's empty.

    • Public Field Mask: String field #

      What shows in place of each character, like "•", or "" for the characters themselves.

    • Public Field TextLook: Style field #

      How its text looks, and its placeholder.

    • Public Field PlaceholderLook: Style field #

      How its placeholder looks.

    • Public New(text: String = "") constructor #

      An input holding text, its cursor after it.

    • Public Property Text: String property #

      What's typed; setting it puts the cursor at its end.

    • Public Property Cursor: Int property #

      Where the cursor is, a byte position in Text.

    • Public Method HandleKey(key: KeyEvent): Bool method #

      Edits it as key says, and gives whether the key was one it takes.

    • Public Method HandleEvent(event: InputEvent): Bool method #

      Takes a key, or what's pasted, its line breaks as spaces, and gives whether it took it.

    • Public Method Draw(canvas: Canvas, area: Region): Int method #

      Draws it in area's first row, and gives the column its cursor is at, for a Screen's ShowCursor.

    Report an issue with this page or with FutureBlitz on GitHub.