From 53183b2411f10dbaf1a0b85ded1d2bd8b6df5ea9 Mon Sep 17 00:00:00 2001 From: Michael Drake Date: Tue, 31 Jul 2012 22:18:44 +0100 Subject: Make text input widget remove caret on "strip focus" event. --- framebuffer/fbtk/text.c | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) (limited to 'framebuffer') diff --git a/framebuffer/fbtk/text.c b/framebuffer/fbtk/text.c index 69e82153d..879d88888 100644 --- a/framebuffer/fbtk/text.c +++ b/framebuffer/fbtk/text.c @@ -413,9 +413,9 @@ text_input(fbtk_widget_t *widget, fbtk_callback_info *cbi) return 0; } -/** Routine called when text events occour in writeable widget. +/** Routine called when click events occour in writeable widget. * - * @param widget The widget reciving input events. + * @param widget The widget reciving click events. * @param cbi The callback parameters. * @return The callback result. */ @@ -447,6 +447,20 @@ text_input_click(fbtk_widget_t *widget, fbtk_callback_info *cbi) return 0; } +/** Routine called when "stripped of focus" event occours for writeable widget. + * + * @param widget The widget reciving "stripped of focus" event. + * @param cbi The callback parameters. + * @return The callback result. + */ +static int +text_input_strip_focus(fbtk_widget_t *widget, fbtk_callback_info *cbi) +{ + fbtk_set_caret(widget, false, 0, 0, 0, NULL); + + return 0; +} + /* exported function documented in fbtk.h */ void fbtk_writable_text(fbtk_widget_t *widget, fbtk_enter_t enter, void *pw) @@ -546,6 +560,7 @@ fbtk_create_writable_text(fbtk_widget_t *parent, fbtk_set_handler(neww, FBTK_CBT_REDRAW, fb_redraw_text, NULL); fbtk_set_handler(neww, FBTK_CBT_CLICK, text_input_click, pw); + fbtk_set_handler(neww, FBTK_CBT_STRIP_FOCUS, text_input_strip_focus, NULL); fbtk_set_handler(neww, FBTK_CBT_INPUT, text_input, neww); return neww; -- cgit v1.2.3