summaryrefslogtreecommitdiffstats
path: root/source/widgets/textbox.c
diff options
context:
space:
mode:
Diffstat (limited to 'source/widgets/textbox.c')
-rw-r--r--source/widgets/textbox.c31
1 files changed, 26 insertions, 5 deletions
diff --git a/source/widgets/textbox.c b/source/widgets/textbox.c
index c0761f11..f527b7a5 100644
--- a/source/widgets/textbox.c
+++ b/source/widgets/textbox.c
@@ -106,11 +106,31 @@ static int textbox_get_desired_height ( widget *wid )
return height;
}
-textbox* textbox_create ( const char *name, TextboxFlags flags, TextBoxFontType tbft, const char *text )
+static gboolean textbox_editable_trigger_action ( widget *wid, MouseBindingMouseDefaultAction action, gint x, gint y, G_GNUC_UNUSED void *user_data )
+{
+ textbox *tb = (textbox *) wid;
+ switch ( action )
+ {
+ case MOUSE_CLICK_DOWN:
+ {
+ gint i;
+ pango_layout_xy_to_index ( tb->layout, x * PANGO_SCALE, y * PANGO_SCALE, &i, NULL );
+ textbox_cursor ( tb, i );
+ return TRUE;
+ }
+ case MOUSE_CLICK_UP:
+ case MOUSE_DCLICK_DOWN:
+ case MOUSE_DCLICK_UP:
+ break;
+ }
+ return FALSE;
+}
+
+textbox* textbox_create_full ( WidgetType type, const char *name, TextboxFlags flags, TextBoxFontType tbft, const char *text )
{
textbox *tb = g_slice_new0 ( textbox );
- widget_init ( WIDGET ( tb ), name );
+ widget_init ( WIDGET ( tb ), type, name );
tb->widget.draw = textbox_draw;
tb->widget.free = textbox_free;
@@ -162,7 +182,8 @@ textbox* textbox_create ( const char *name, TextboxFlags flags, TextBoxFontType
tb->blink_timeout = 0;
tb->blink = 1;
if ( ( flags & TB_EDITABLE ) == TB_EDITABLE ) {
- tb->blink_timeout = g_timeout_add ( 1200, textbox_blink, tb );
+ tb->blink_timeout = g_timeout_add ( 1200, textbox_blink, tb );
+ tb->widget.trigger_action = textbox_editable_trigger_action;
}
// Enabled by default
@@ -799,13 +820,13 @@ int textbox_get_estimated_height ( const textbox *tb, int eh )
}
int textbox_get_desired_width ( widget *wid )
{
- textbox *tb = (textbox *) wid;
+ textbox *tb = (textbox *) wid;
unsigned int offset = ( tb->flags & TB_INDICATOR ) ? DOT_OFFSET : 0;
if ( tb->flags & TB_AUTOWIDTH ) {
return textbox_get_font_width ( tb ) + widget_padding_get_padding_width ( wid ) + offset;
}
int width = 0;
- pango_layout_set_width ( tb->layout, -1);
+ pango_layout_set_width ( tb->layout, -1 );
width = textbox_get_font_width ( tb );
// Restore.
pango_layout_set_width ( tb->layout, PANGO_SCALE * ( tb->widget.w - widget_padding_get_padding_width ( WIDGET ( tb ) ) - offset ) );