Click or drag to resize
DigitalRuneUIControlHitTest Method
Tests if a position is over a control.

Namespace: DigitalRune.Game.UI.Controls
Assembly: DigitalRune.Game.UI (in DigitalRune.Game.UI.dll) Version: 1.8.0.0 (1.8.0.14553)
Syntax
protected virtual bool HitTest(
	UIControl control,
	Vector2F position
)

Parameters

control
Type: DigitalRune.Game.UI.ControlsUIControl
The control. If , the position is checked against this control.
position
Type: DigitalRune.Mathematics.AlgebraVector2F
The position.

Return Value

Type: Boolean
if a mouse click at the position can hit control.
Remarks

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.

See Also