Commits

Lars Brubaker  committed c0a6877

Made the app not unselect a text control when you alt-tab away and back.

  • Participants
  • Parent commits 064bb3a

Comments (0)

Files changed (3)

File Gui/GUIWidget.cs

 
 namespace MatterHackers.Agg.UI
 {
-    public class WidgetEventArgs : EventArgs
-    {
-        GUIWidget widget;
-        public GUIWidget Widget { get { return widget; } }
-
-        public WidgetEventArgs(GUIWidget widget)
-        {
-            this.widget = widget;
-        }
-    }
-
     public abstract class GUIWidget
     {
         // this should probably some type of dirty rects with the current invalid set stored.
         public delegate void EnabledChangedEventHandler(object sender, EventArgs e);
         public event EnabledChangedEventHandler EnabledChanged;
 
-        public delegate void ChildAddedEventHandler(object sender, WidgetEventArgs widgetEvent);
+        public delegate void ChildAddedEventHandler(object sender, EventArgs widgetEvent);
         public event ChildAddedEventHandler ChildAdded;
 
-        public delegate void ChildRemovedEventHandler(object sender, WidgetEventArgs widgetEvent);
+        public delegate void ChildRemovedEventHandler(object sender, EventArgs widgetEvent);
         public event ChildRemovedEventHandler ChildRemoved;
 
         public GUIWidget()
             }
         }
 
+        public virtual void OnLostFocus(EventArgs e)
+        {
+            if (LostFocus != null)
+            {
+                LostFocus(this, e);
+            }
+        }
+
+        public virtual void OnGotFocus(EventArgs e)
+        {
+            if (GotFocus != null)
+            {
+                GotFocus(this, e);
+            }
+        }
+
         void AllocateBackBuffer()
         {
             rect_d localBounds = LocalBounds;
         {
             child.parent = this;
             children.Add(child);
-            OnChildAdded(new WidgetEventArgs(child));
+            OnChildAdded(child);
             child.OnParentChanged();
 
             child.InitLayout();
             child.PerformLayout();
         }
 
-        public virtual void OnChildAdded(WidgetEventArgs widgetEvent)
+        public virtual void OnChildAdded(Object sender)
         {
             if (ChildAdded != null)
             {
         {
             child.parent = null;
             children.Remove(child);
-            OnChildRemoved(new WidgetEventArgs(child));
+            OnChildRemoved(child);
             child.OnParentChanged();
         }
 
-        public virtual void OnChildRemoved(WidgetEventArgs widgetEvent)
+        public virtual void OnChildRemoved(Object sender)
         {
             if (ChildRemoved != null)
             {
-                ChildRemoved(this, widgetEvent);
+                ChildRemoved(sender, null);
             }
         }
 
                 if (Focused)
                 {
                     containsFocus = false;
-                    OnLostFocus();
+                    OnLostFocus(null);
                     return;
                 }
 
             }
         }
 
-        public virtual void OnLostFocus()
-        {
-            if (LostFocus != null)
-            {
-                LostFocus(this, null);
-            }
-        }
-
         public bool CanFocus
         {
             get

File Gui/TextEditWidget.cs

             base.OnFocus();
         }
 
-        public override void OnLostFocus()
+        public override void OnLostFocus(EventArgs e)
         {
             Invalidate();
             if (textWhenGotFocus != Text)
             {
                 OnTextChanged();
             }
-            base.OnLostFocus();
+            base.OnLostFocus(e);
         }
 
         public override void OnDraw(Graphics2D graphics2D)

File PlatformWin32/win32/WindowsFormsAbstract.cs

         }
 
         protected override void OnLostFocus(EventArgs e)
-        {
-            aggAppWidget.Unfocus();
+        {
+            aggAppWidget.OnLostFocus(e);
             base.OnLostFocus(e);
         }
 
         protected override void OnGotFocus(EventArgs e)
-        {
-            aggAppWidget.Focus();
+        {
+            aggAppWidget.OnGotFocus(e);
             base.OnGotFocus(e);
         }