Public Member Functions | |
TextInput () | |
virtual | ~TextInput () |
std::wstring | text () const |
void | setText (const std::wstring &text) |
Replaces the current text by the given string and positions the cursor at the end of the text, with an empty selection. | |
unsigned | caretPos () const |
Position of the caret as the index of the character that it's left to. | |
void | setCaretPos (unsigned pos) |
Sets the caret position as returned by caretPos. | |
unsigned | selectionStart () const |
If there is a selection, the selectionStart() member yields its beginning, using the same indexing scheme as caretPos. | |
void | setSelectionStart (unsigned pos) |
Sets the start of the selection as returned by selectionStart. | |
virtual std::wstring | filter (const std::wstring &textIn) const |
Overridable filter that is applied to all new text that is entered. |
At its most basic form, you only need to create a new TextInput instance and pass it to your window via setTextInput. Until you call this function again, passing 0, the TextInput object will build a text that can be accessed via TextInput::text(). A TextInput object is purely abstract, though; drawing the input field is left to the user. As with most of Gosu, how this is handled is completely left open. TextInput only aims to provide enough code for your own GUIs to build upon.
Definition at line 23 of file TextInput.hpp.
Gosu::TextInput::TextInput | ( | ) |
virtual Gosu::TextInput::~TextInput | ( | ) | [virtual] |
unsigned Gosu::TextInput::caretPos | ( | ) | const |
Position of the caret as the index of the character that it's left to.
virtual std::wstring Gosu::TextInput::filter | ( | const std::wstring & | textIn | ) | const [virtual] |
Overridable filter that is applied to all new text that is entered.
Allows for context-sensitive filtering/extending/... of the text. The text will be inserted at caretPos afterwards.
Definition at line 63 of file TextInput.hpp.
unsigned Gosu::TextInput::selectionStart | ( | ) | const |
If there is a selection, the selectionStart() member yields its beginning, using the same indexing scheme as caretPos.
If there is no selection, selectionStart() is equal to caretPos().
void Gosu::TextInput::setCaretPos | ( | unsigned | pos | ) |
Sets the caret position as returned by caretPos.
You usually also want to use setSelectionStart.
void Gosu::TextInput::setSelectionStart | ( | unsigned | pos | ) |
Sets the start of the selection as returned by selectionStart.
void Gosu::TextInput::setText | ( | const std::wstring & | text | ) |
Replaces the current text by the given string and positions the cursor at the end of the text, with an empty selection.
std::wstring Gosu::TextInput::text | ( | ) | const |