feat(text_input): add draw function

This commit is contained in:
Kevin Baumgartner
2026-05-07 21:12:02 +02:00
parent dbbd40b58a
commit b625acdd60
+24
View File
@@ -17,4 +17,28 @@ class TextInput:
self.active_border_color = (0, 255, 0) self.active_border_color = (0, 255, 0)
self.background_color = (30, 30, 30) 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