Environment.GetEntityUnderMouseCursor Method

Returns the index of the first top level entity under the mouse cursor.
Public Function GetEntityUnderMouseCursor( _ 
ByVal mousePos As Point, _ 
Optional ByVal selectableOnly As Boolean = true _ 
) As Integer
This language is not supported or no code example is available.
public int GetEntityUnderMouseCursor( 
Point mousePos
bool selectableOnly = true 
)
This language is not supported or no code example is available.

Parameters

mousePos
Point

Mouse position in screen coordinates

selectableOnly
bool

When true, checks the Entity.Selectable property, otherwise no.

Return Value

int

The index of the entity, -1 otherwise.

Remarks
 
The sensitivity is affected by the PickBoxSize parameter.
Example
 
The following code fragment demonstrate how to highlight the entity under the mouse cursor.
 private void viewportProfessional1_MouseMove(
          object sender, MouseEventArgs e)
 {
 
    viewportProfessional1.ClearSelection();
 
    int id = viewportProfessional1.GetEntityUnderMouseCursor(e.Location);
 
    if (id != -1)
    {
 
       Entity ent = viewportProfessional1.Entities[id] as Entity;
 
       ent.Selected = true;
 
    }
 
    viewportProfessional1.Invalidate();
 
 }
     					
This language is not supported or no code example is available.
 Private Sub ViewportProfessional1_Move( _
           ByVal sender As System.Object, _
           ByVal e As System.EventArgs) _
           Handles ViewportProfessional1.Move
 
    ViewportProfessional1.ClearSelection()
 
    Dim id As Integer = ViewportProfessional1.GetEntityUnderMouseCursor( _
          e.Location)
 
    If id <> -1 Then
 
       Dim ent As Entity = ViewportProfessional1.Entities(id)
 
       ent.Selected = True
 
    End If
 
    ViewportProfessional1.Invalidate()
 
 End Sub
     					
This language is not supported or no code example is available.

.NET Framework

Supported in: 4.8

In this article

Definition