Nez.UI.Element.hit C# (CSharp) Method

hit() public method

public hit ( Vector2 point ) : Element
point Vector2
return Element
		public virtual Element hit( Vector2 point )
		{
			// if we are not Touchable or us or any parent is not visible bail out
			if( touchable != Touchable.Enabled || !areParentsVisible() )
				return null;

			if( point.X >= 0 && point.X < width && point.Y >= 0 && point.Y < height )
				return this;
			return null;
		}

Usage Example

        public override Element hit(Vector2 point)
        {
            // we do some rejiggering here by checking for hits on our target and using that
            var local = _targetElement.screenToLocalCoordinates(point);

            if (_targetElement.hit(local) != null)
            {
                if (!_isMouseOver)
                {
                    _isMouseOver = true;
                    _manager.enter(this);
                }
                setContainerPosition(local.X, local.Y);
            }
            else if (_isMouseOver)
            {
                _isMouseOver = false;
                _manager.hide(this);
            }
            return(null);
        }