diff mde/gui/widget/AParentWidget.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/AParentWidget.d	Fri Jan 23 14:59:05 2009 +0000
+++ b/mde/gui/widget/AParentWidget.d	Fri Jan 23 16:05:05 2009 +0000
@@ -23,6 +23,7 @@
 
 public import mde.gui.widget.AChildWidget;
 import mde.gui.exception;
+import mde.content.Content;
 
 debug {
     import tango.util.log.Log : Log, Logger;
@@ -72,13 +73,13 @@
         throw new GuiException ("getWidgetIndex: widget not found (code error)");
     }
     
-    // Don't override; use the WIDGET_TYPE.SAFE_RECURSION flag for safe widgets.
-    //NOTE: should be override (compiler bug)
-    final void recursionCheck (widgetID a) {
+    // Parents taking a content should override, only throwing if both the
+    // widget id and the content are the same (as its it and content).
+    override void recursionCheck (widgetID wID, IContent c) {
         debug assert (id !is null && parent !is null, "recursionCheck called before parent and id set");
-        if (a is id)
-            throw new GuiException ("Infite recursion of "~a);
-        parent.recursionCheck (a);
+        if (wID is id)
+            throw new WidgetRecursionException (wID);
+        parent.recursionCheck (wID, c);
     }
     
     IPopupParentWidget getParentIPPW () {
@@ -151,7 +152,10 @@
     override bool menuActive () {
         return mAIPPW;
     }
-    
+    override bool parentMenuActive () {
+        return parentIPPW.menuActive;
+    }
+   
     override void menuDone () {	// default actions, for popup menus:
         parentIPPW.removeChildIPPW (this);	// remove self
         parentIPPW.menuDone;			// and propegate