ArduinoLibs
Public Member Functions
TextField Class Reference

Field that displays a read-only text value. More...

#include <TextField.h>

Inheritance diagram for TextField:
Field

List of all members.

Public Member Functions

 TextField (const String &label)
 Constructs a new text field with a specific label.
 TextField (Form &form, const String &label, const String &value)
 Constructs a new text field with a specific label and value attaches it to a form.
void enterField (bool reverse)
 Enters the field due to form navigation.
const String & value () const
 Returns the text value that is currently displayed by this field.
void setValue (const String &value)
 Sets the text value that is displayed by this field.

Detailed Description

Field that displays a read-only text value.

This following example displays a text field with the label "Form example" and a value() of "v1.0".

 Form mainForm(lcd);
 TextField welcomeField(mainForm, "Form example", "v1.0");
FormText.png

As well as static messages, TextField can be used to display read-only information that is computed at runtime:

 TextField timeField(mainForm, "Time since reset", "0");

 void loop() {
     timeField.setValue(millis() / 1000);
     mainForm.dispatch(lcd.getButton());
 }

For writable fields, use BoolField, IntField, or TimeField.

See also:
Field

Definition at line 28 of file TextField.h.


Constructor & Destructor Documentation

TextField::TextField ( const String &  label) [explicit]

Constructs a new text field with a specific label.

The field is initially not associated with a Form. The field can be added to a form later using Form::addField().

The initial value() will be the empty string.

See also:
Form::addField()

Definition at line 66 of file TextField.cpp.

TextField::TextField ( Form form,
const String &  label,
const String &  value 
)

Constructs a new text field with a specific label and value attaches it to a form.

See also:
value()

Definition at line 77 of file TextField.cpp.


Member Function Documentation

void TextField::enterField ( bool  reverse) [virtual]

Enters the field due to form navigation.

This function is typically called when the user presses Left and Right buttons to navigate to the field. If reverse is true, then navigation was due to the Left button being pressed.

This function can assume that the display has been cleared and the cursor is positioned at (0, 0).

The default implementation prints the label().

See also:
exitField()

Reimplemented from Field.

Definition at line 83 of file TextField.cpp.

void TextField::setValue ( const String &  value)

Sets the text value that is displayed by this field.

See also:
value()

Definition at line 102 of file TextField.cpp.

const String & TextField::value ( ) const [inline]

Returns the text value that is currently displayed by this field.

See also:
setValue()

Definition at line 35 of file TextField.h.


The documentation for this class was generated from the following files:
 All Classes Files Functions Variables Enumerations Enumerator