-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTextBox.hpp
More file actions
40 lines (29 loc) · 902 Bytes
/
TextBox.hpp
File metadata and controls
40 lines (29 loc) · 902 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
#ifndef TEXTBOX_HPP
#define TEXTBOX_HPP
#include <SFML/Graphics.hpp>
#include <string>
#include "UIObject.hpp"
#define DELETE_KEY 8
#define ENTER_KEY 13
#define ESCAPE_KEY 27
class TextBox : public UIObject
{
public:
TextBox();
TextBox(const sf::Vector2f& pos,int textSize, sf::Color textColor, const sf::Font& font, size_t characteLimit);
public:
void update(sf::RenderWindow& window, const sf::Vector2f& mousePos, const UserInput& userInput) override;
void draw(sf::RenderWindow& window) const override;
void reset() override;
void setActive(bool value) override;
void setString(const std::string& str);
void setPosition(const sf::Vector2f& position) override;
std::string getString();
private:
sf::Font font;
sf::Text text;
size_t cursorID;
std::string str;
int limit;
};
#endif