From f13e00b41189fafb2eebd3df214e19db9fb107b7 Mon Sep 17 00:00:00 2001 From: Emmanuele Bassi Date: Thu, 11 Dec 2008 12:10:46 +0000 Subject: [PATCH] Truncate selections on text insertion When inserting text on a key press event we should also truncate the selection. We should not truncate the selection when inserting any Unicode character, since changing the selection also changes the cursor position - and one of the invariants we inherited from ClutterEntry is that inserting characters programmatically does not change the cursor position. --- clutter/clutter-text.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/clutter/clutter-text.c b/clutter/clutter-text.c index baec33d76..284c33d5d 100644 --- a/clutter/clutter-text.c +++ b/clutter/clutter-text.c @@ -898,7 +898,8 @@ static gboolean clutter_text_key_press (ClutterActor *actor, ClutterKeyEvent *event) { - ClutterTextPrivate *priv = CLUTTER_TEXT (actor)->priv; + ClutterText *self = CLUTTER_TEXT (actor); + ClutterTextPrivate *priv = self->priv; ClutterBindingPool *pool; gboolean res; gint keyval; @@ -925,7 +926,8 @@ clutter_text_key_press (ClutterActor *actor, if (g_unichar_validate (key_unichar)) { - clutter_text_insert_unichar (CLUTTER_TEXT (actor), key_unichar); + clutter_text_truncate_selection (self); + clutter_text_insert_unichar (self, key_unichar); return TRUE; }