summaryrefslogtreecommitdiff
path: root/src/gui/text_widget.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/gui/text_widget.c')
-rw-r--r--src/gui/text_widget.c12
1 files changed, 10 insertions, 2 deletions
diff --git a/src/gui/text_widget.c b/src/gui/text_widget.c
index dc12c11..f6ba8eb 100644
--- a/src/gui/text_widget.c
+++ b/src/gui/text_widget.c
@@ -12,8 +12,8 @@ static text_widget_vtable_t text_widget_vtable = {
widget_on_mouse_down,
widget_on_mouse_up,
widget_on_mouse_move,
- widget_on_key_down,
- widget_on_key_up
+ text_widget_on_key_down,
+ text_widget_on_key_up
},
text_widget_set_text
};
@@ -25,6 +25,8 @@ void text_widget_init( text_widget_t *widget, widget_t *parent, const int x, con
widget_init( &widget->base, parent, x, y, w, h, background_color );
text_widget_set_text( widget, s );
+
+ widget->base.focusable = true;
widget->base.vtable = (widget_vtable_t *)&text_widget_vtable;
widget->vtable = &text_widget_vtable;
@@ -64,6 +66,12 @@ void text_widget_set_text( void *obj, const char *s )
void text_widget_on_key_down( void *obj, char c )
{
+ text_widget_t *widget = obj;
+
+ if( strlen( widget->s ) < TEXT_WIDGET_MAX_TEXT_SIZE - 1 ) {
+ widget->s[strlen( widget->s )] = c;
+ widget->s[strlen( widget->s )+1] = '\0';
+ }
}
void text_widget_on_key_up( void *obj, char c )