UIControlHitTest Method |
Namespace: DigitalRune.Game.UI.Controls
The default implementation returns if control is this control or and if the position is within the ActualBounds. The default implementation returns always if control is a control other than this control.
HitTest(UIControl, Vector2F) is automatically called during the input traversal of the visual tree to set the IsMouseOver flag in the InputContext. It is not recommended to call HitTest(UIControl, Vector2F) manually.
This method can be used in two ways:
A) myControl.HitTest(null, position) is called to check if the position is within this control. HitTest(UIControl, Vector2F) can be changed in derived classes to create controls where the hit zone is not rectangular, e.g. a round button.
B) parent.HitTest(child, position) is automatically called by a parent control (e.g. a ContentControl) during the input traversal to check "if the parent allows the child to be hit". HitTest(UIControl, Vector2F) can be changed in derived classes to clip the hit zone of the child. For example, a ScrollViewer (which is derived from ContentControl) will only return true if the position of the child is within the viewport. The child itself does not know that part of it is invisible.