Works even more now

This commit is contained in:
Rasmus Rasmussen 2026-01-17 11:13:34 +01:00
parent 83d02a8861
commit 44a4c2ceba
3 changed files with 14 additions and 6 deletions

View File

@ -69,7 +69,12 @@ public:
}
if (text.selected && event.event == CLICK_EVENTS::KEYBOARD) {
if ((text.x + text.width) >= (_window->x + _window->width)) {
text.text += "\n";
Serial.println("Aight");
}
text.text += event.character;
_tft->get_text_bounds(text.text, text.size, text.width, text.height);
}
}
}
@ -90,15 +95,11 @@ public:
text.selected = false;
text.text = "asddsa";
_tft->get_text_bounds(text.text, text.size, text.width, text.height);
_window->window_content_text.push_back(text);
while (_running) {
for (WindowContentText text : _window->window_content_text) {
if (text.selected) {
}
}
vTaskDelay(pdMS_TO_TICKS(1));
}
}

View File

@ -59,3 +59,9 @@ void TFT_Handler::fill_screen(short color) {
void TFT_Handler::push_sprite() {
sprite.pushSprite(0, 0);
}
void TFT_Handler::get_text_bounds(const std::string& str, short size, short& width, short& height) {
sprite.setTextSize(size);
width = sprite.textWidth(str.c_str());
height = sprite.fontHeight() * size;
}

View File

@ -68,4 +68,5 @@ public:
void draw_button(short x, short y, short size_x, short size_y, short color, bool pressed, std::string str);
void fill_screen(short color);
void push_sprite();
void get_text_bounds(const std::string& str, short size, short& width, short& height);
};