Smartmobili.Cocoa.NSView.IsDescendantOf C# (CSharp) Method

IsDescendantOf() public method

public IsDescendantOf ( NSView aView ) : bool
aView NSView
return bool
        public virtual bool IsDescendantOf(NSView aView)
        {
            id self = this;

            if (aView == self)
                return true;

            if (_super_view == null)
                return false;

            if (_super_view == aView)
                return true;

            return _super_view.IsDescendantOf(aView);
        }

Usage Example

Example #1
0
        /**
         * Returns self if aView is the receiver or aView is a subview of the receiver,
         * the ancestor view shared by aView and the receiver if any, or
         * aView if it is an ancestor of the receiver, otherwise returns nil.
         */
        public virtual NSView AncestorSharedWithView(NSView aView)
        {
            NSView self = this;

            if (self == aView)
                return self;

            if (this.IsDescendantOf(aView))
                return aView;

            if (aView.IsDescendantOf(self))
                return self;

            /*
             * If neither are descendants of each other and either does not have a
             * superview then they cannot have a common ancestor
             */
            if (_super_view == null)
                return null;

            if (aView.Superview == null)
                return null;

            /* Find the common ancestor of superviews */
            return _super_view.AncestorSharedWithView((NSView)aView.Superview);
        }
NSView