[longomatch] Fix function to change focus in widgets



commit 381b3b42fc6553f33021376db7bec95f2de11a93
Author: Andoni Morales Alastruey <ylatuya gmail com>
Date:   Thu Oct 23 12:23:20 2014 +0200

    Fix function to change focus in widgets

 LongoMatch.GUI.Helpers/Misc.cs |   14 +++++++++++---
 1 files changed, 11 insertions(+), 3 deletions(-)
---
diff --git a/LongoMatch.GUI.Helpers/Misc.cs b/LongoMatch.GUI.Helpers/Misc.cs
index bc4ff61..08e8bce 100644
--- a/LongoMatch.GUI.Helpers/Misc.cs
+++ b/LongoMatch.GUI.Helpers/Misc.cs
@@ -260,14 +260,22 @@ namespace LongoMatch.Gui.Helpers
                                return LoadMissingIcon (size);
                        }
                }
-               
+
+               static bool IsSkipedType (Widget w, Type[] skipTypes)
+               {
+                       return skipTypes.Count (t => w.GetType().IsSubclassOf(t)) > 0;
+               }
+
                public static void SetFocus (Container w, bool canFocus, params Type[] skipTypes) {
+                       if (IsSkipedType (w, skipTypes)) {
+                               return;
+                       }
                        w.CanFocus = canFocus;
                        foreach (Widget child in w.AllChildren) {
                                if (child is Container) {
-                                       SetFocus (child as Container, canFocus);
+                                       SetFocus (child as Container, canFocus, skipTypes);
                                } else {
-                                       if (!skipTypes.Contains (child.GetType())) {
+                                       if (IsSkipedType (child, skipTypes)) {
                                                child.CanFocus = canFocus;
                                        }
                                }


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