here is monkeypatching proof of concept, use bbox to get coordinates of the listitem, math, compare to mouse coordinates
#!/usr/bin/perl --
$Devel::Trace::TRACE = 0; ## off
use strict; use warnings;
use Tk;
my $mw = MainWindow ->new ;
my $listFrame = $mw->Frame->pack;
my $listBox = $listFrame->Scrolled(
'Listbox',
-scrollbars => 'osoe',
-selectmode => 'extended',
-background => 'white',
-height => 10,
-width => 10,
-selectborderwidth => 0,
-relief => 'flat', )->pack;
$listBox->insert('end', qw/red yellow green blue grey/);
@ARGV and eval { require Tk::WidgetDump; $mw->WidgetDump; };
MainLoop;
exit 0;
# BeginSelect --
#
# This procedure is typically invoked on button-1 presses. It begins
# the process of making a selection in the listbox. Its exact behavior
# depends on the selection mode currently in effect for the listbox;
# see the Motif documentation for details.
#
# Arguments:
# w - The listbox widget.
# el - The element for the selection operation (typically the
# one under the pointer). Must be in numerical form.
sub Tk::Listbox::BeginSelect {
package Tk::Listbox;
use vars qw/ @Selection $Prev /;
$Devel::Trace::TRACE = 1; ## on
my $w = shift;
my $el = shift;
if ( $w->cget('-selectmode') eq 'multiple' ) {
if ( $w->selectionIncludes($el) ) {
$w->selectionClear($el);
}
else {
$w->selectionSet($el);
}
}
else {
## fix it here
my ( $iltx, $ilty, $iw, $ih ) = $w->bbox($el);
my $rooty = $listBox->rooty;
my $evY = $Tk::event->Y;
my $ylt = $rooty + $ilty + $ih;
print "$ylt < $evY\n";
if ( $ylt < $evY ) {
### clear the board when clicking off the end
### no selection
### anchor
$w->selectionClear( 0, 'end' )
} else { ## the original logic
$w->selectionClear( 0, 'end' );
$w->selectionSet($el);
$w->selectionAnchor($el);
}
@Selection = ();
$Prev = $el;
}
$w->focus if ( $w->cget('-takefocus') );
$w->eventGenerate("<<ListboxSelect>>");
$Devel::Trace::TRACE = 0; ## off
}