Move cursor always to the end of a text entry widget on entering the edit state instead of remembering the cursor position from the last edit because
- this is plainly the expected behaviour
- in almost all cases the user either wants to append text or delete text (and as Contiki only supports a <backspace> but no <delete> action this means positioning the cursor to the end as well)
diff --git a/contiki/ctk/ctk.c b/contiki/ctk/ctk.c
index 31c9160..330f76e 100644
--- a/contiki/ctk/ctk.c
+++ b/contiki/ctk/ctk.c
@@ -43,7 +43,7 @@
  *
  * This file is part of the Contiki operating system.
  *
- * $Id: ctk.c,v 1.47 2005/05/04 21:50:17 oliverschmidt Exp $
+ * $Id: ctk.c,v 1.48 2005/05/04 22:33:45 oliverschmidt Exp $
  *
  */
 
@@ -1177,6 +1177,16 @@
 }
 #endif /* CTK_CONF_MENUS */
 /*-----------------------------------------------------------------------------------*/
+static void CC_FASTCALL
+textentry_edit(CC_REGISTER_ARG struct ctk_textentry *t)
+{
+  t->state = CTK_TEXTENTRY_EDIT;
+  t->xpos = strlen(t->text);
+  if(t->xpos == t->len) {
+    --t->xpos;
+  }
+}
+/*-----------------------------------------------------------------------------------*/
 static unsigned char CC_FASTCALL 
 activate(CC_REGISTER_ARG struct ctk_widget *w)
 {
@@ -1207,12 +1217,8 @@
     ek_post(EK_BROADCAST, ctk_signal_hyperlink_activate, w);
   } else if(w->type == CTK_WIDGET_TEXTENTRY) {
     if(w->widget.textentry.state == CTK_TEXTENTRY_NORMAL) {      
-      w->widget.textentry.state = CTK_TEXTENTRY_EDIT;
-      w->widget.textentry.xpos = strlen(w->widget.textentry.text);
-      if(w->widget.textentry.xpos == w->widget.textentry.len) {
-	--w->widget.textentry.xpos;
-      }
-    } else if(w->widget.textentry.state == CTK_TEXTENTRY_EDIT) {
+      textentry_edit((struct ctk_textentry *)w);
+    } else {
       w->widget.textentry.state = CTK_TEXTENTRY_NORMAL;
       ek_post(w->window->owner, ctk_signal_widget_activate, w);
     }
@@ -1748,7 +1754,9 @@
 	  } else {
 	    if(widget != NULL &&
 	       widget->type == CTK_WIDGET_TEXTENTRY) {
-	      widget->widget.textentry.state = CTK_TEXTENTRY_EDIT;
+	      if(widget->widget.textentry.state == CTK_TEXTENTRY_NORMAL) {
+		textentry_edit((struct ctk_textentry *)widget);
+	      }
 	      textentry_input(c, (struct ctk_textentry *)widget);
 	      add_redrawwidget(widget);
 	    } else {