Make text input widget remove caret on "strip focus" event.

This commit is contained in:
Michael Drake 2012-07-31 22:18:44 +01:00
parent 9505fdcf84
commit 53183b2411
1 changed files with 17 additions and 2 deletions

View File

@ -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;