Glyph.GetHitTest(Point) Metodo

Definizione

Fornisce la logica di hit test.

public:
 abstract System::Windows::Forms::Cursor ^ GetHitTest(System::Drawing::Point p);
public abstract System.Windows.Forms.Cursor GetHitTest (System.Drawing.Point p);
public abstract System.Windows.Forms.Cursor? GetHitTest (System.Drawing.Point p);
abstract member GetHitTest : System.Drawing.Point -> System.Windows.Forms.Cursor
Public MustOverride Function GetHitTest (p As Point) As Cursor

Parametri

p
Point

Punto da sottoporre a hit test.

Restituisce

Oggetto Cursor se l'oggetto Glyph è associato a p; in caso contrario, null.

Esempio

Nell'esempio seguente viene illustrato come eseguire l'override dell'oggetto GetHitTest per verificare se il punto si trova all'interno di questo glifo. Questo esempio di codice fa parte di un esempio più grande fornito per la BehaviorService classe.

public:
    virtual Cursor^ GetHitTest(Point p) override
    {
        // GetHitTest is called to see if the point is
        // within this glyph.  This gives us a chance to decide
        // what cursor to show.  Returning null from here means
        // the mouse pointer is not currently inside of the
        // glyph.  Returning a valid cursor here indicates the
        // pointer is inside the glyph, and also enables our
        // Behavior property as the active behavior.
        if (Bounds.Contains(p))
        {
            return Cursors::Hand;
        }
        return nullptr;
    }
public override Cursor GetHitTest(Point p)
{
    // GetHitTest is called to see if the point is
    // within this glyph.  This gives us a chance to decide
    // what cursor to show.  Returning null from here means
    // the mouse pointer is not currently inside of the glyph.
    // Returning a valid cursor here indicates the pointer is
    // inside the glyph, and also enables our Behavior property
    // as the active behavior.
    if (Bounds.Contains(p))
    {
        return Cursors.Hand;
    }

    return null;
}
Public Overrides Function GetHitTest(ByVal p As Point) As Cursor
    ' GetHitTest is called to see if the point is
    ' within this glyph.  This gives us a chance to decide
    ' what cursor to show.  Returning null from here means
    ' the mouse pointer is not currently inside of the glyph.
    ' Returning a valid cursor here indicates the pointer is
    ' inside the glyph,and also enables our Behavior property
    ' as the active behavior.
    If Bounds.Contains(p) Then
        Return Cursors.Hand
    End If

    Return Nothing

End Function

Commenti

Il GetHitTest metodo è un abstract metodo che forza Glyph le implementazioni a fornire la logica di hit test. Dato qualsiasi punto, se l'oggetto Glyph ha deciso di essere coinvolto in tale posizione, sarà necessario restituire un oggetto valido Cursor. In caso contrario, la restituzione null causerà l'ignorare BehaviorService la posizione.

Si applica a

Vedi anche