#include <TextBox.h>
Public Types | |
enum | InputMode { TEXT = 0x01, PASSWORD = 0x02 } |
Public Member Functions | |
const char * | getTypeName () const |
unsigned int | getCaretLocation () const |
void | setCaretLocation (unsigned int index) |
int | getLastKeypress () |
void | setPasswordChar (char character) |
char | getPasswordChar () const |
void | setInputMode (InputMode inputMode) |
InputMode | getInputMode () const |
virtual void | addListener (Control::Listener *listener, int eventFlags) |
Static Public Member Functions | |
static TextBox * | create (const char *id, Theme::Style *style=NULL) |
Protected Member Functions | |
TextBox () | |
~TextBox () | |
void | initialize (const char *typeName, Theme::Style *style, Properties *properties) |
bool | touchEvent (Touch::TouchEvent evt, int x, int y, unsigned int contactIndex) |
bool | keyEvent (Keyboard::KeyEvent evt, int key) |
void | controlEvent (Control::Listener::EventType evt) |
void | updateState (State state) |
unsigned int | drawImages (Form *form, const Rectangle &clip) |
unsigned int | drawText (Form *form, const Rectangle &clip) |
std::string | getDisplayedText () const |
Static Protected Member Functions | |
static Control * | create (Theme::Style *style, Properties *properties=NULL) |
static InputMode | getInputMode (const char *inputMode) |
Protected Attributes | |
unsigned int | _caretLocation |
Vector2 | _prevCaretLocation |
int | _lastKeypress |
unsigned int | _fontSize |
Theme::ThemeImage * | _caretImage |
char | _passwordChar |
InputMode | _inputMode |
bool | _ctrlPressed |
bool | _shiftPressed = false |
Defines a text control.
Listeners can listen for a TEXT_CHANGED event, and then query the text box for the last keypress it received. On mobile device you can tap or click within the text box to bring up the virtual keyboard.
gameplay::TextBox::TextBox | ( | ) | [protected] |
Constructor.
gameplay::TextBox::~TextBox | ( | ) | [protected] |
Destructor.
virtual void gameplay::TextBox::addListener | ( | Control::Listener * | listener, |
int | eventFlags | ||
) | [virtual] |
Add a listener to be notified of specific events affecting this control. Event types can be OR'ed together. E.g. To listen to touch-press and touch-release events, pass Control::Listener::TOUCH | Control::Listener::RELEASE
as the second parameter.
listener | The listener to add. |
eventFlags | The events to listen for. |
Reimplemented from gameplay::Label.
void gameplay::TextBox::controlEvent | ( | Control::Listener::EventType | evt | ) | [protected, virtual] |
Reimplemented from gameplay::Control.
static TextBox* gameplay::TextBox::create | ( | const char * | id, |
Theme::Style * | style = NULL |
||
) | [static] |
Creates a new TextBox.
id | The textbox ID. |
style | The textbox style (optional). |
Reimplemented from gameplay::Label.
static Control* gameplay::TextBox::create | ( | Theme::Style * | style, |
Properties * | properties = NULL |
||
) | [static, protected] |
Create a text box with a given style and properties.
style | The style to apply to this text box. |
properties | A properties object containing a definition of the text box (optional). |
Reimplemented from gameplay::Label.
unsigned int gameplay::TextBox::drawImages | ( | Form * | form, |
const Rectangle & | clip | ||
) | [protected, virtual] |
Reimplemented from gameplay::Control.
unsigned int gameplay::TextBox::drawText | ( | Form * | form, |
const Rectangle & | clip | ||
) | [protected, virtual] |
Reimplemented from gameplay::Label.
unsigned int gameplay::TextBox::getCaretLocation | ( | ) | const |
Returns the current location of the caret with the text of this TextBox.
std::string gameplay::TextBox::getDisplayedText | ( | ) | const [protected] |
Get the text which should be displayed, depending on _inputMode.
InputMode gameplay::TextBox::getInputMode | ( | ) | const |
Get the input mode.
static InputMode gameplay::TextBox::getInputMode | ( | const char * | inputMode | ) | [static, protected] |
Gets an InputMode by string.
inputMode | The string representation of the InputMode type. |
Get the last key pressed within this text box.
char gameplay::TextBox::getPasswordChar | ( | ) | const |
Get the character displayed in password mode.
const char* gameplay::TextBox::getTypeName | ( | ) | const [virtual] |
Extends ScriptTarget::getTypeName() to return the type name of this class.
Child controls should override this function to return the correct type name.
Reimplemented from gameplay::Label.
void gameplay::TextBox::initialize | ( | const char * | typeName, |
Theme::Style * | style, | ||
Properties * | properties | ||
) | [protected, virtual] |
Reimplemented from gameplay::Label.
bool gameplay::TextBox::keyEvent | ( | Keyboard::KeyEvent | evt, |
int | key | ||
) | [protected, virtual] |
Keyboard callback on key events.
evt | The key event that occurred. |
key | If evt is KEY_PRESS or KEY_RELEASE then key is the key code from Keyboard::Key. If evt is KEY_CHAR then key is the unicode value of the character. |
Reimplemented from gameplay::Control.
void gameplay::TextBox::setCaretLocation | ( | unsigned int | index | ) |
Sets the location of the caret within this text box.
index | The new location of the caret within the text of this TextBox. |
void gameplay::TextBox::setInputMode | ( | InputMode | inputMode | ) |
Set the input mode.
inputMode | Input mode to set. |
void gameplay::TextBox::setPasswordChar | ( | char | character | ) |
Set the character displayed in password mode.
character | Character to display in password mode. |
bool gameplay::TextBox::touchEvent | ( | Touch::TouchEvent | evt, |
int | x, | ||
int | y, | ||
unsigned int | contactIndex | ||
) | [protected, virtual] |
Touch callback on touch events. Controls return true if they consume the touch event.
evt | The touch event that occurred. |
x | The x position of the touch in pixels. Left edge is zero. |
y | The y position of the touch in pixels. Top edge is zero. |
contactIndex | The order of occurrence for multiple touch contacts starting at zero. |
Reimplemented from gameplay::Control.
void gameplay::TextBox::updateState | ( | State | state | ) | [protected, virtual] |
Reimplemented from gameplay::Label.
Theme::ThemeImage* gameplay::TextBox::_caretImage [protected] |
The Theme::Image for the TextBox's caret.
unsigned int gameplay::TextBox::_caretLocation [protected] |
The current location of the TextBox's caret.
bool gameplay::TextBox::_ctrlPressed [protected] |
Indicate if the CTRL key is currently pressed.
unsigned int gameplay::TextBox::_fontSize [protected] |
The font size to be used in the TextBox.
InputMode gameplay::TextBox::_inputMode [protected] |
The mode used to display the typed text.
int gameplay::TextBox::_lastKeypress [protected] |
The last character that was entered into the TextBox.
char gameplay::TextBox::_passwordChar [protected] |
The character displayed in password mode.
Vector2 gameplay::TextBox::_prevCaretLocation [protected] |
The previous position of the TextBox's caret.
bool gameplay::TextBox::_shiftPressed = false [protected] |
Indicate if the SHIFT key is currently pressed.