diff --git a/framebuffer/fbtk.h b/framebuffer/fbtk.h index 61050f46f..2098caf53 100644 --- a/framebuffer/fbtk.h +++ b/framebuffer/fbtk.h @@ -400,6 +400,13 @@ void fbtk_writable_text(fbtk_widget_t *widget, fbtk_enter_t enter, void *pw); void fbtk_set_text(fbtk_widget_t *widget, const char *text); +/** Give widget input focus. + * + * @param widget Widget to be given input focus. + */ +void fbtk_set_focus(fbtk_widget_t *widget); + + /** enable the on screen keyboard for input */ diff --git a/framebuffer/fbtk/event.c b/framebuffer/fbtk/event.c index c1ddaeeb0..c1c4bc1ee 100644 --- a/framebuffer/fbtk/event.c +++ b/framebuffer/fbtk/event.c @@ -52,8 +52,10 @@ fbtk_input(fbtk_widget_t *root, nsfb_event_t *event) /* obtain widget with input focus */ input = root->u.root.input; - if (input == NULL) + if (input == NULL) { + LOG(("No widget has input focus.")); return; /* no widget with input */ + } fbtk_post_callback(input, FBTK_CBT_INPUT, event); } diff --git a/framebuffer/fbtk/fbtk.c b/framebuffer/fbtk/fbtk.c index 92586ebce..5aef6bd45 100644 --- a/framebuffer/fbtk/fbtk.c +++ b/framebuffer/fbtk/fbtk.c @@ -685,6 +685,18 @@ fbtk_post_callback(fbtk_widget_t *widget, fbtk_callback_type cbt, ...) return ret; } +/* exported function docuemnted in fbtk.h */ +void +fbtk_set_focus(fbtk_widget_t *widget) +{ + fbtk_widget_t *root; + + /* ensure we have the root widget */ + root = fbtk_get_root_widget(widget); + + root->u.root.input = widget; +} + /* exported function docuemnted in fbtk.h */ diff --git a/framebuffer/gui.c b/framebuffer/gui.c index 3da849421..575a4c972 100644 --- a/framebuffer/gui.c +++ b/framebuffer/gui.c @@ -1245,6 +1245,8 @@ create_normal_browser_window(struct gui_window *gw, int furniture_width) /* browser widget */ create_browser_widget(gw, toolbar_height, option_fb_furniture_size); + /* Give browser_window's user widget input focus */ + fbtk_set_focus(gw->browser); }