Example #1
0
 public static boolean isParent(Control parent, Control child) {
   for (Control c = child; c != null; c = c.getParent()) {
     if (c == parent) {
       return true;
     }
   }
   return false;
 }
Example #2
0
 /**
  * Determine whether this control or any of it's child has focus
  *
  * @param control control to check
  * @return true if it has focus
  */
 public static boolean hasFocus(Control control) {
   Control focusControl = control.getDisplay().getFocusControl();
   if (focusControl == null) {
     return false;
   }
   for (Control fc = focusControl; fc != null; fc = fc.getParent()) {
     if (fc == control) {
       return true;
     }
   }
   return false;
 }