ArduinoLibs
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
Public Member Functions | List of all members
TextField Class Reference

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

#include <TextField.h>

Inheritance diagram for TextField:
Field

Public Member Functions

 TextField (const String &label)
 Constructs a new text field with a specific label. More...
 
 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. More...
 
void enterField (bool reverse)
 Enters the field due to form navigation. More...
 
const String & value () const
 Returns the text value that is currently displayed by this field. More...
 
void setValue (const String &value)
 Sets the text value that is displayed by this field. More...
 
- Public Member Functions inherited from Field
 Field (const String &label)
 Constructs a new field with a specific label. More...
 
 Field (Form &form, const String &label)
 Constructs a new field with a specific label and attaches it to a form.
 
 ~Field ()
 Destroys this field and removes it from its owning Form. More...
 
Formform () const
 Returns the Form that owns this field; null if not associated with a Form.
 
virtual int dispatch (int event)
 Dispatches event via this field. More...
 
virtual void exitField ()
 Exits the field due to form navigation. More...
 
const String & label () const
 Returns the label to display in the first line of this field. More...
 
void setLabel (const String &label)
 Sets the label to display in the first line of this field. More...
 
bool isCurrent () const
 Returns true if this field is the currently-displayed field in its owning form; false otherwise. More...
 

Additional Inherited Members

- Protected Member Functions inherited from Field
LiquidCrystal * lcd () const
 Returns the LCD that this field is being drawn on.
 
virtual void updateCursor ()
 Updates the cursor position after the label has been drawn by setLabel(). More...
 

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: