From be64cbcdc22952ce2fa9f902e153e3bd9f4a08c9 Mon Sep 17 00:00:00 2001 From: Emmanuele Bassi Date: Mon, 15 Dec 2008 18:46:08 +0000 Subject: [PATCH] Fix up/down key navigation The behaviour of ClutterText around the initial position is still a little bit erratic. This commit fixes the key navigation with Up and Down arrows around the first line of text. --- clutter/clutter-text.c | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/clutter/clutter-text.c b/clutter/clutter-text.c index 7d2a077..51c29f2 100644 --- a/clutter/clutter-text.c +++ b/clutter/clutter-text.c @@ -1209,20 +1209,24 @@ clutter_text_real_move_up (ClutterText *self, layout = clutter_text_get_layout (self); - pango_layout_index_to_line_x (layout, - offset_to_bytes (priv->text, priv->position), + if (priv->position == 0) + index_ = 0; + else + index_ = offset_to_bytes (priv->text, priv->position); + + pango_layout_index_to_line_x (layout, index_, 0, &line_no, &x); + line_no -= 1; + if (line_no < 0) + return FALSE; + if (priv->x_pos != -1) x = priv->x_pos; else priv->x_pos = x; - line_no -= 1; - if (line_no < 0) - return FALSE; - layout_line = pango_layout_get_line_readonly (layout, line_no); if (!layout_line) return FALSE; @@ -1256,8 +1260,12 @@ clutter_text_real_move_down (ClutterText *self, layout = clutter_text_get_layout (self); - pango_layout_index_to_line_x (layout, - offset_to_bytes (priv->text, priv->position), + if (priv->position == 0) + index_ = 0; + else + index_ = offset_to_bytes (priv->text, priv->position); + + pango_layout_index_to_line_x (layout, index_, 0, &line_no, &x); -- 2.7.4