Finding an Index by y Coordinate

If you know a y coordinate in the Listbox, you can determine the index of the nearest Listbox item to it by using the nearest method:

$index = $lb->nearest(y)

The nearest method returns a number that corresponds to the index of the closest visible Listbox item.

Get Mastering Perl/Tk now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.