X-Git-Url: https://git.artsoft.org/?a=blobdiff_plain;f=src%2Fbuttons.c;h=7c1e9c9a0ee99bf9a1c84d1ffb1a2fddbdf8dad7;hb=refs%2Ftags%2F1.3.0;hp=9c19a36ae9198fd65e0727d18a6e7cf6307f53e3;hpb=e985382cdedf6fbfb89d64e429c0da56754b9e7c;p=rocksndiamonds.git diff --git a/src/buttons.c b/src/buttons.c index 9c19a36a..7c1e9c9a 100644 --- a/src/buttons.c +++ b/src/buttons.c @@ -1862,7 +1862,7 @@ static void HandleGadgetTags(struct GadgetInfo *gi, int first_tag, va_list ap) case GDI_INFO_TEXT: { - int max_textsize = MAX_INFO_TEXTSIZE; + int max_textsize = MAX_INFO_TEXTSIZE - 1; strncpy(gi->info_text, va_arg(ap, char *), max_textsize); gi->info_text[max_textsize] = '\0'; @@ -2273,14 +2273,19 @@ void RemapAllGadgets() MultiMapGadgets(MULTIMAP_ALL | MULTIMAP_REMAP); } -void ClickOnGadget(struct GadgetInfo *gi) +boolean anyTextGadgetActive() +{ + return (last_gi && last_gi->type & GD_TYPE_TEXTINPUT && last_gi->mapped); +} + +void ClickOnGadget(struct GadgetInfo *gi, int button) { /* simulate releasing mouse button over last gadget, if still pressed */ if (button_status) HandleGadgets(-1, -1, 0); /* simulate pressing mouse button over specified gadget */ - HandleGadgets(gi->x, gi->y, 1); + HandleGadgets(gi->x, gi->y, button); /* simulate releasing mouse button over specified gadget */ HandleGadgets(gi->x, gi->y, 0); @@ -2292,7 +2297,7 @@ void HandleGadgets(int mx, int my, int button) static unsigned long pressed_delay = 0; static int last_button = 0; static int last_mx = 0, last_my = 0; - int scrollbar_mouse_pos; + int scrollbar_mouse_pos = 0; struct GadgetInfo *new_gi, *gi; boolean press_event; boolean release_event; @@ -2325,8 +2330,7 @@ void HandleGadgets(int mx, int my, int button) last_my = my; /* special treatment for text and number input gadgets */ - if (last_gi && last_gi->type & GD_TYPE_TEXTINPUT && last_gi->mapped && - button != 0 && !motion_status) + if (anyTextGadgetActive() && button != 0 && !motion_status) { struct GadgetInfo *gi = last_gi;