1 #include <Interface/Menu/MenuItemTextbox.hpp>
2 #include <Config/Globals.hpp>
3 #include <Flow/InputManager.hpp>
4 #include <Misc/Utils.hpp>
6 MenuItemTextbox::MenuItemTextbox(std::string label,
int id,
int width, std::string initial):
22 if ((
int)(this->currentText.size()) > (this->width))
23 window->
print(this->currentText.substr(this->width), (posx - this->width), y, Globals::Theme::textbox);
25 window->
print(this->currentText, (posx - this->width), y, Globals::Theme::textbox);
27 int spacex = (posx - this->width) - this->currentText.size();
30 for (
unsigned int i = 0; i < (this->width - this->currentText.size()); i++)
31 window->
printChar(
' ', spacex + i, y, Globals::Theme::textbox);
37 bool isPrintable(
int input)
39 return ((input > 32) && (input < 127));
44 if (InputManager::noKeyPressed())
47 if (isPrintable(InputManager::pressedKey))
49 this->currentText += (char)(InputManager::pressedKey);
53 if (InputManager::isPressed(KEY_BACKSPACE))
54 Utils::String::pop_back(this->currentText);