ListBox.GetItemAtLocation(int x, int y)
Determines which item in the list box is at the screen co-ordinates (X,Y).
This allows you to find out which item the mouse is hovering over, for instance.
Returns the item index (where the first item is 0), or -1 if the specified co-ordinates
are not over any item or are outside the list box.
Example:
int index = lstOptions.GetItemAtLocation(mouse.x, mouse.y);
if (index < 0) {
Display("The mouse is not over an item!");
}
else {
String selectedItem = lstOptions.Items[index];
Display("The mouse is over item '%s'.", selectedItem);
}
will display the item text that the mouse is currently hovering over.
See Also: ListBox.SelectedIndex
|