From b625acdd60e0919216e7aae24a002b38d675235d Mon Sep 17 00:00:00 2001 From: Kevin Baumgartner Date: Thu, 7 May 2026 21:12:02 +0200 Subject: [PATCH] feat(text_input): add draw function --- src/text_input.py | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/src/text_input.py b/src/text_input.py index e215b96..6272f3b 100644 --- a/src/text_input.py +++ b/src/text_input.py @@ -16,5 +16,29 @@ class TextInput: self.border_color = (255, 255, 255) self.active_border_color = (0, 255, 0) self.background_color = (30, 30, 30) - + def handle_event(self, event): + # todo check keyboard input events + pass + + def draw(self, screen): + # draw background of input box + pygame.draw.rect(screen, self.background_color, self.rect) + + # change border color depending if input box is active or not + if self.active: + border_color = self.active_border_color + else: + border_color = self.border_color + + # draw border + pygame.draw.rect(screen, border_color, self.rect, 2) + + # draw text + text_surface = self.font.render(self.text, True, self.text_color) + + # show text with indentation + screen.blit(text_surface, (self.rect.x + 10, self.rect.y + 10)) + + def get_text(self): + return self.text