MCPcopy Create free account
hub / github.com/Hopson97/HopsonCraft / input

Method input

Source/GUI/Text_Box.cpp:24–60  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

22 }
23
24 void Text_Box::input(const sf::Event& e)
25 {
26 if (e.type == sf::Event::TextEntered)
27 {
28 if (m_isActive)
29 {
30 char code = e.text.unicode;
31 if ((code >= 32 && code <= 126) &&
32 (code != 47) && //Back slash
33 (code != 92) && //Forward slash
34 m_inputtedText->length() <= m_maxLength) //Lowercase
35 {
36 *m_inputtedText += (static_cast<char>(e.text.unicode));
37 }
38 else if (code == 8 && m_inputtedText->length() >= 1)
39 {
40 m_inputtedText->pop_back();
41 }
42 }
43 }
44 else if (e.type == sf::Event::MouseButtonPressed)
45 {
46 if (e.mouseButton.button == sf::Mouse::Left)
47 {
48 if (touchingMouse(m_quad))
49 {
50 m_quad.setFillColor({200, 200, 200});
51 m_isActive = true;
52 }
53 else
54 {
55 m_quad.setFillColor(sf::Color::White);
56 m_isActive = false;
57 }
58 }
59 }
60 }
61
62 void Text_Box::update()
63 {

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected