21 #include <SFML/UI/Focusable.hpp>
22 #include <SFML/UI/IText.hpp>
23 #include <SFML/UI/Model/TextFieldModel.hpp>
52 TextField(sf::Texture
const &texture, sf::Texture
const &textureFocused, sf::String
const &text =
"");
64 TextField(sf::Texture
const &texture, sf::Texture
const &textureFocused, sf::Font
const &font, sf::String text =
"");
76 virtual void draw(sf::RenderTarget& target, sf::RenderStates states)
const;
97 virtual bool insertText(sf::Uint32 text,
unsigned int index);
155 virtual const sf::String&
getText()
const;
165 virtual void setText(sf::String
const &text);
172 virtual const sf::Font*
getFont()
const;
179 virtual void setFont(sf::Font
const &font);
264 unsigned int m_cursor;
265 sf::RectangleShape m_cursorShape;
void setCursor(unsigned int cursor)
Sets the cursor's position.
void setModel(TextFieldModel *model)
Sets the model of the text field.
The base class for all UI components that can be focused.
virtual void setFont(sf::Font const &font)
Sets the font of the component's text.
void setMaxLength(int maxLength)
Sets the max length that the string can have -1 means the string has no length limit.
void setCanBeEmpty(bool canBeEmpty)
Sets if the string can be empty.
virtual unsigned int getFontSize() const
TextField()
Creates an empty text field without texture, font ...
A text field which stores a text.
virtual void draw(sf::RenderTarget &target, sf::RenderStates states) const
Draw the component to the render target.
virtual void updateFixed(sf::Time delta)
Update the component with the main loop's frequency Can be useful for animation, or time's needed stu...
const TextFieldModel * getModel() const
virtual sf::Color getFontColor() const
virtual void updateCoord()
Called when the component need update its geometry Inherit when you need to update some sprite...
virtual void setFontColor(sf::Color color)
Sets the color's font of the text.
virtual void updateEvent(sf::Event const &event)
Update the component each time an event has been polled.
unsigned int getCursor() const
virtual const sf::Font * getFont() const
virtual const sf::String & getText() const
The abstract class that defines what can be typed into the text field.
An interface that allow component to have a text.
virtual void setText(sf::String const &text)
Sets the text's string of the component Don't forget to set the font.
virtual bool insertText(sf::Uint32 text, unsigned int index)
Insert a char at the given index Trigger a TextEnteredEvent.
virtual bool deleteText(unsigned int index)
Delete the char at the given index Trigger a TextDeletedEvent.
virtual void setFontSize(unsigned int size)
Set the font's size of the component.