-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTextfeld.cpp
More file actions
44 lines (37 loc) · 816 Bytes
/
Textfeld.cpp
File metadata and controls
44 lines (37 loc) · 816 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
41
42
43
44
#include "Textfeld.h"
#include "SFML\Network.hpp"
#include "App.h"
#include <iostream>
Textfeld::Textfeld(App &app, sf::Vector2f pos, sf::Vector2f size, sf::Color backColor, sf::Color textColor) : Label(pos, size, "", backColor, textColor), m_app(app)
{
}
Textfeld::~Textfeld(void)
{
}
bool Textfeld::textEntered(sf::Event &event)
{
if (event.type == sf::Event::TextEntered)
{
std::string string = getString();
if(event.text.unicode == '\b')
{
if(!string.empty())
{
string.erase(string.size() - 1, 1);
updateString(string);
}
}
else if (event.text.unicode < 128)
{
string += static_cast<char>(event.text.unicode);
updateString(string);
}
return true;
}
return false;
}
void Textfeld::updateString(std::string &string)
{
setString(string);
m_app.setIP(string);
}