[hyena] Add MenuButton.Menu setter



commit e91524cc873de4d4d05d3c5ed4d928b260c79993
Author: Gabriel Burt <gabriel burt gmail com>
Date:   Wed Feb 17 16:49:05 2010 -0800

    Add MenuButton.Menu setter

 src/Hyena.Gui/Hyena.Widgets/MenuButton.cs |   18 ++++++++++++++++--
 1 files changed, 16 insertions(+), 2 deletions(-)
---
diff --git a/src/Hyena.Gui/Hyena.Widgets/MenuButton.cs b/src/Hyena.Gui/Hyena.Widgets/MenuButton.cs
index 138bb86..0971859 100644
--- a/src/Hyena.Gui/Hyena.Widgets/MenuButton.cs
+++ b/src/Hyena.Gui/Hyena.Widgets/MenuButton.cs
@@ -55,8 +55,7 @@ namespace Hyena.Widgets
             WidgetFlags |= WidgetFlags.NoWindow;
 
             button_widget = buttonWidget;
-            this.menu = menu;
-            menu.Deactivated += delegate { toggle_button.Active = false; };
+            Menu = menu;
 
             toggle_button.Parent = this;
             toggle_button.FocusOnClick = false;
@@ -88,6 +87,21 @@ namespace Hyena.Widgets
 
         public Menu Menu {
             get { return menu; }
+            set {
+                if (menu == value)
+                    return;
+
+                if (menu != null)
+                    menu.Deactivated -= OnMenuDeactivated;
+
+                menu = value;
+                menu.Deactivated += OnMenuDeactivated;
+            }
+        }
+
+        private void OnMenuDeactivated (object o, EventArgs args)
+        {
+            toggle_button.Active = false;
         }
 
         protected ToggleButton ToggleButton {



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]