#include "entry.hpp" #include "text.hpp" void entry_character_callback(GLFWwindow* window, unsigned int codepoint){ #include entry* e = (entry*)glfwGetWindowUserPointer(window); e->append((char)codepoint); } void entry_key_callback(GLFWwindow* window, int key, int scancode, int action, int mods){ entry* e = (entry*)glfwGetWindowUserPointer(window); if(key == GLFW_KEY_BACKSPACE&&(action == GLFW_PRESS || action == GLFW_REPEAT)){ e->backspace(); } } entry::entry(){} entry::entry(GLFWwindow* win,float x, float y, float width, float height): Widget{x,y,width,height}{ text+="hoi"; } void entry::select(GLFWwindow* win){ glfwSetWindowUserPointer(win, this); glfwSetKeyCallback(win, entry_key_callback); glfwSetCharCallback(win, entry_character_callback); } void entry::Draw(float screenRatio){ Widget::Draw(screenRatio); //Text playGameText(text.c_str(), rectangle,screenRatio); Text playGameText(text.c_str(), rectangle,screenRatio); playGameText.Draw(); playGameText.Delete(); } void entry::append(char c){ text+=c; } void entry::backspace(){ if(!text.empty()){ text.erase(text.end()-1); } }