diff mde/gui/widget/PopupMenu.d @ 133:9fd705793568

Fixed menu popup bug, improved recursion detection. Menu popups can now determine whether or not they are sub-menus. Recursion detection can now also check content (if not the same, there's not a risk of infinite recursion).
author Diggory Hardy <diggory.hardy@gmail.com>
date Fri, 23 Jan 2009 16:05:05 +0000
parents 9cff74f68b84
children 9f035cd139c6
line wrap: on
line diff
--- a/mde/gui/widget/PopupMenu.d	Fri Jan 23 14:59:05 2009 +0000
+++ b/mde/gui/widget/PopupMenu.d	Fri Jan 23 16:05:05 2009 +0000
@@ -51,6 +51,12 @@
 	h = mh;
     }
     
+    override void recursionCheck (widgetID wID, IContent c) {
+        if (wID is id && c is content)
+            throw new WidgetRecursionException (wID);
+        parent.recursionCheck (wID, c);
+    }
+
     override int clickEvent (wdabs, wdabs, ubyte b, bool state) {
 	if (b == 1 && state == true) {
 	    if (!pushed) {
@@ -58,10 +64,7 @@
                 parentIPPW.menuActive = true;
                 mgr.positionPopup (this, popup);
                 pushed = true;
-            } else {
-                // NOTE: perhaps shouldn't do anything when
-                // parentIPPW.parentIPPW.menuActive
-                // (this causes funny behaviour when clicking a submenu):
+            } else if (!parentIPPW.parentMenuActive) {	// if not a submenu
                 parentIPPW.removeChildIPPW (this);
             }
 	}
@@ -77,7 +80,8 @@
         if (state && !pushed && parentIPPW.menuActive) {
             parentIPPW.addChildIPPW (this);
             menuActive = true;
-            mgr.positionPopup (this, popup, 1);	// causes redraw
+            mgr.positionPopup (this, popup,
+                               parentIPPW.parentMenuActive ? 1 : 0);
             pushed = true;
         }
     }