1
0
Fork 0
mirror of https://github.com/davatorium/rofi.git synced 2025-02-03 15:34:54 -05:00

Fix converting x,y to cursor position.

This commit is contained in:
Dave Davenport 2017-06-03 18:39:37 +02:00
parent 8b7ceb9286
commit 5bc8ea29a5

View file

@ -115,8 +115,17 @@ static WidgetTriggerActionResult textbox_editable_trigger_action ( widget *wid,
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 );
// substract padding on left.
x -= widget_padding_get_left ( wid );
gint max = textbox_get_font_width ( tb );
// Right of text, move to end.
if ( x >= max ){
textbox_cursor_end ( tb );
} else if ( x > 0 ) {
// If in range, get index.
pango_layout_xy_to_index ( tb->layout, x * PANGO_SCALE, y * PANGO_SCALE, &i, NULL );
textbox_cursor ( tb, i );
}
return WIDGET_TRIGGER_ACTION_RESULT_HANDLED;
}
case MOUSE_CLICK_UP: