|
virtual void | draw (DrawingContext &context) override |
|
virtual bool | on_mouse_button_up (const SDL_MouseButtonEvent &button) override |
|
virtual bool | on_mouse_button_down (const SDL_MouseButtonEvent &button) override |
|
virtual bool | on_mouse_motion (const SDL_MouseMotionEvent &motion) override |
|
virtual bool | on_key_up (const SDL_KeyboardEvent &key) override |
|
virtual bool | on_key_down (const SDL_KeyboardEvent &key) override |
|
virtual bool | event (const SDL_Event &ev) override |
|
virtual void | update (float dt_sec) override |
|
void | bind_string (std::string *value) |
| Binds a string to the textbox.
|
|
const std::string & | get_string () const |
| Returns the full string held in m_charlist.
|
|
int | get_text_position (const Vector &pos) const |
| Gets at which (absolute) index, in the text, corresponds an on-screen point.
|
|
bool | fits (const std::string &text) const |
| Returns true if the given text would fit inside the box.
|
|
bool | copy () const |
| Copies the current selected text to the clipboard. More...
|
|
bool | paste () |
| Pastes the text from the clipboard. More...
|
|
std::string | get_selected_text () const |
|
bool | erase_selected_text () |
|
bool | put_text (const std::string &text) |
| Puts the given text at the currently selected position, replacing the text that was selected, if any. More...
|
|
void | set_focus (bool focus) |
|
bool | has_focus () const |
|
void | set_rect (const Rectf &rect) |
|
Rectf | get_rect () const |
|
virtual void | setup () |
|
virtual void | resize () |
|
virtual bool | on_mouse_wheel (const SDL_MouseWheelEvent &wheel) |
|
|
virtual bool | parse_value (bool call_on_change=true) |
| Transfers the string into the binded variable, if any. More...
|
|
virtual void | revert_value () |
| Reverts the contents of the char vector to the value of the member variable. More...
|
|
std::string | get_contents () const |
| WARNING : These function returns the status of the string as the user types, and therefore are unsuited for callers expecting a validated value. More...
|
|
std::string | get_first_chars (int amount) const |
| Returns first "amount" chars held in m_charlist.
|
|
std::string | get_contents_visible () const |
| Returns the part of the string that is actually displayed.
|
|
std::string | get_first_chars_visible (int amount) const |
| Returns first "amount" chars that are displayed.
|
|
void | delete_char_before_caret () |
|
std::string | get_truncated_text (const std::string &text) const |
| Returns the largest string fitting in the box. More...
|
|
void | recenter_offset () |
| Changes m_current_offset so that the caret is visible.
|
|
◆ copy()
bool ControlTextbox::copy |
( |
| ) |
const |
Copies the current selected text to the clipboard.
If no text is selected, does nothing and returns false.
- Returns
- true if copied successfully, false if error OR nothing was selected.
◆ erase_selected_text()
bool ControlTextbox::erase_selected_text |
( |
| ) |
|
- Returns
- true if some text was selected and therefore erased.
◆ get_contents()
std::string ControlTextbox::get_contents |
( |
| ) |
const |
|
protected |
WARNING : These function returns the status of the string as the user types, and therefore are unsuited for callers expecting a validated value.
If such case is, use get_string() instead. If you use these functions below, you'll get a half-typed value! (And don't validate while the user is typing, it could make typing impossible!)Converts the internal char vector to an actual string and returns it.
◆ get_selected_text()
std::string ControlTextbox::get_selected_text |
( |
| ) |
const |
- Returns
- the text currently selected by the user.
◆ get_truncated_text()
std::string ControlTextbox::get_truncated_text |
( |
const std::string & |
text | ) |
const |
|
protected |
Returns the largest string fitting in the box.
◆ parse_value()
bool ControlTextbox::parse_value |
( |
bool |
call_on_change = true | ) |
|
|
protectedvirtual |
Transfers the string into the binded variable, if any.
Can be overridden by children if they use different value members (like float, int, etc). parse_value MUST make the validation, and MUST use get_contents() to fetch the string to parse, as get_string() will return the precedent valid string.
- Parameters
-
call_on_change | Whether calling this function should also call m_on_change(). Children classes that implement another m_value member (float, int, etc.) should call ControlTextbox::parse_value(false) to parse the string without calling m_on_change immediately; the child class should call m_on_change() by itself when and only when they have parsed their value. |
- Returns
- Whether or not the value in the textbox was a valid value. If it isn't, then parse_value() should handle reverting the char vector to its last valid state.
- See also
- get_string()
-
revert_value()
Reimplemented in ControlTextboxFloat, and ControlTextboxInt.
◆ paste()
bool ControlTextbox::paste |
( |
| ) |
|
Pastes the text from the clipboard.
If the clipboard doesn't have text, does nothing and returns false.
- Returns
- true if pasted successfully, false if error OR cliboard was empty/non-text
◆ put_text()
bool ControlTextbox::put_text |
( |
const std::string & |
text | ) |
|
Puts the given text at the currently selected position, replacing the text that was selected, if any.
- Returns
- true if some text was deleted; false if no text was replaced.
◆ revert_value()
void ControlTextbox::revert_value |
( |
| ) |
|
|
protectedvirtual |
◆ m_charlist
std::list<char> ControlTextbox::m_charlist |
|
protected |
Holds the list of characters that are in the textbox.
When characters are added or deleted, this is the member variable that is getting edited.
◆ m_internal_string_backup
std::string ControlTextbox::m_internal_string_backup |
|
protected |
◆ m_string
std::string* ControlTextbox::m_string |
|
protected |
◆ m_validate_string
bool(* ControlTextbox::m_validate_string) (ControlTextbox *, std::string) |
Optional, a function to validate the string.
If nullptr, then all values are assumed to be valid.
- Parameters
-
ControlTextbox* | A pointer to the original control. |
std::string | The string that is about to be applied to the textbox. |
- Returns
- Whether or not this value is valid. If not, then the internal string will not be modified. Tip : You can manually change the string using set_string() inside this function and return false to establish a custom value (for example, a max string length).
The documentation for this class was generated from the following files: