rnd-19990205-1
[rocksndiamonds.git] / src / buttons.c
index 9c19a36ae9198fd65e0727d18a6e7cf6307f53e3..7c1e9c9a0ee99bf9a1c84d1ffb1a2fddbdf8dad7 100644 (file)
@@ -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;