From f7b47bbe40b05bc4d815f94dd1bcdc21596d4ff5 Mon Sep 17 00:00:00 2001 From: Holger Schemel Date: Sat, 29 Sep 2018 10:20:41 +0200 Subject: [PATCH] changed setting cursor when automatically activating text input gadgets When activating text input gadgets using function "ClickOnGadget()", do not set the cursor position at the start, but at the end of the text in the gadget. --- src/libgame/gadgets.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/libgame/gadgets.c b/src/libgame/gadgets.c index 4cf008fc..64f0e0a9 100644 --- a/src/libgame/gadgets.c +++ b/src/libgame/gadgets.c @@ -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) -- 2.34.1