HeaderPane
Main
Hide
Share Link
Print

Hit Testing

The SftMask.HitTest method returns the part of the control at a location in client coordinates, for example to show a tooltip or a context menu of the application's own:

ValueDescription
HitAreaEnum.EditThe input area.
HitAreaEnum.LabelThe label.
HitAreaEnum.UpButtonThe up button.
HitAreaEnum.DownButtonThe down button.
HitAreaEnum.EllipseButtonThe ellipse button.
HitAreaEnum.NoneOutside the control's parts, such as the border.

The SftMask.GetCharIndexFromPosition method returns the boundary between positions closest to a location, from 0 to the number of positions; the SftMask.GetPositionFromCharIndex method returns the location of a position, and the SftMask.GetCharBounds method the rectangle covering a range of positions.

C#

private void sftMask1_MouseMove(object sender, MouseEventArgs e) {
    if (sftMask1.HitTest(e.Location) == HitAreaEnum.Label)
        toolTip1.SetToolTip(sftMask1, "Amounts are in US dollars");
    else
        toolTip1.SetToolTip(sftMask1, null);
}

VB

Private Sub SftMask1_MouseMove(sender As Object, e As MouseEventArgs) Handles SftMask1.MouseMove
    If SftMask1.HitTest(e.Location) = HitAreaEnum.Label Then
        ToolTip1.SetToolTip(SftMask1, "Amounts are in US dollars")
    Else
        ToolTip1.SetToolTip(SftMask1, Nothing)
    End If
End Sub