[AD] new mouse focus patch

[ Thread Index | Date Index | More lists.liballeg.org/allegro-developers Archives ]


Following Elias' comments, here is a new patch which renames the flag to its logical opposite, and makes the patch more intuitive.

I had a look at my code this weekend (I originally wrote this patch months ago) and noticed that I wasn't using it for the example I gave :) In fact, I have two patches to that function, one of which had been rejected already (the MOUSEBLIND one).

So, this new message is used by map map pin widgets, which are pins that are placed on the minimap of the area, and that the user can drag and drop. These are pin-shaped, not rectangular.

Anyway, here's the new patch:

--- src/gui.c.mouse_object      Fri Nov  7 11:18:20 2003
+++ src/gui.c   Fri Nov  7 11:26:35 2003
@@ -433,13 +435,20 @@
 {
    int mouse_object = -1;
    int c;
+   int res;
    ASSERT(d);

-   for (c=0; d[c].proc; c++)
+   for (c=0; d[c].proc; c++) {
       if ((gui_mouse_x() >= d[c].x) && (gui_mouse_y() >= d[c].y) &&
          (gui_mouse_x() < d[c].x + d[c].w) && (gui_mouse_y() < d[c].y + d[c].h) &&
-         (!(d[c].flags & (D_HIDDEN | D_DISABLED))))
-        mouse_object = c;
+         (!(d[c].flags & (D_HIDDEN | D_DISABLED)))) {
+         /* check if this object wants the mouse */
+         res = object_message(d+c, MSG_WANTMOUSE, 0);
+         if (!(res & D_DONTWANTMOUSE)) {
+            mouse_object = c;
+         }
+      }
+   }

    return mouse_object;
 }
--- include/allegro/gui.h.mouse_object  Fri Nov  7 11:18:43 2003
+++ include/allegro/gui.h       Fri Nov  7 11:26:42 2003
@@ -116,6 +116,7 @@
 #define D_WANTFOCUS     8        /* this object wants the input focus */
 #define D_USED_CHAR     16       /* object has used the keypress */
 #define D_REDRAW_ALL    32       /* request to redraw all active dialogs */
+#define D_DONTWANTMOUSE 64       /* this object does not want mouse focus */


 /* messages for the dialog procedures */
@@ -142,7 +143,8 @@
 #define MSG_MRELEASE    21       /* mouse middle button released */
 #define MSG_RPRESS      22       /* mouse right button pressed */
 #define MSG_RRELEASE    23       /* mouse right button released */
-#define MSG_USER        24       /* from here on are free... */
+#define MSG_WANTMOUSE   24       /* does object want the mouse? */
+#define MSG_USER        25       /* from here on are free... */


 /* some dialog procedures */


Vincent





Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/