[AD] gui focus in d_menu_proc

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


This is a little patch which makes `d_menu_proc' to lost the focus
of the active object, and to reput the focus in the mouse object
when the loop of the `_do_menu' over.

-- 
David A. Capello
dacap@xxxxxxxxxx
http://www.davidcapello.com.ar
--- gui.c	Fri Oct 12 11:45:06 2001
+++ gui.new.c	Fri Oct 12 11:52:04 2001
@@ -1779,7 +1779,7 @@
 { 
    MENU_INFO m;
    int ret = D_O_K;
-   int x;
+   int x, i;
 
    switch (msg) {
 
@@ -1805,10 +1805,25 @@
 
       case MSG_GOTMOUSE:
       case MSG_CLICK:
+	 /* steal the focus */
+	 i = find_dialog_focus(active_dialog);
+	 if (i >= 0) {
+	    active_dialog[i].flags &= ~D_GOTMOUSE;
+	    SEND_MESSAGE(active_dialog+i, MSG_LOSTMOUSE, 0);
+	 }
+
+	 /* run the menu */
 	 _do_menu(d->dp, NULL, TRUE, d->x-1, d->y-1, FALSE, &x, d->w+2, d->h+2);
 	 ret |= x;
 	 do {
 	 } while (gui_mouse_b());
+
+	 /* put the focus */
+	 i = find_mouse_object(active_dialog);
+	 if (i >= 0) {
+	    active_dialog[i].flags |= D_GOTMOUSE;
+	    SEND_MESSAGE(active_dialog+i, MSG_GOTMOUSE, 0);
+	 }
 	 break;
    }
 


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