- /* simulate releasing mouse button over specified gadget */
- HandleGadgets(gi->x, gi->y, 0);
+ // 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(x, y, button);
+
+ // simulate releasing mouse button over specified gadget
+ HandleGadgets(x, y, 0);