TextAccumulator

Constructor

TextAccumulator <id> (string init_val) // the default value for init_val is the empty string

Action

Accumulates the successive input values. The result is available in the state property. When the delete child is activated, the last character of the string contained in state is deleted.

Predefined children

  • TextProperty: input, state.
  • Spike: delete.

Example


use core
use base
use display
use gui

_main_
Component root {
  Frame f ("myFrame", 0, 0, 500, 500)
  Rectangle del_char (50, 50, 50, 40, 5, 5)

  FillColor _ (0, 0, 0)
  Clock cl (500)
  FSM cursor {
    State hidden
    State visible {
      OutlineColor _ (0, 0, 0)
      OutlineWidth _ (2)
      Line l (0, 111, 0, 121)
    }
    hidden->visible (cl.tick)
    visible->hidden (cl.tick)
  }
  Text test_kbd (50, 120, "")
  test_kbd.x + test_kbd.width + 2 =:> cursor.visible.l.x1, cursor.visible.l.x2
  TextAccumulator acc
  f.key\-pressed_text=>acc.input
  acc.state => test_kbd.text
  del_char.press -> acc.delete
}