changed setting cursor when automatically activating text input gadgets
[rocksndiamonds.git] / src / libgame / gadgets.c
index 4cf008fc01eaaec6044f85d3de57e00bfd4cad36..64f0e0a99d9a57bbedac20d6bc94be28698e82c2 100644 (file)
@@ -1494,11 +1494,18 @@ void ClickOnGadget(struct GadgetInfo *gi, int button)
   if (button_status)
     HandleGadgets(-1, -1, 0);
 
+  int x = gi->x;
+  int y = gi->y;
+
+  /* set cursor position to the end of the text for text input gadgets */
+  if (gi->type & GD_TYPE_TEXT_INPUT)
+    x = gi->x + gi->width - 1;
+
   /* simulate pressing mouse button over specified gadget */
-  HandleGadgets(gi->x, gi->y, button);
+  HandleGadgets(x, y, button);
 
   /* simulate releasing mouse button over specified gadget */
-  HandleGadgets(gi->x, gi->y, 0);
+  HandleGadgets(x, y, 0);
 }
 
 boolean HandleGadgets(int mx, int my, int button)