$Bill
2018-10-02 00:02:13 UTC
Given a frame with a Listbox in it, I can't figure out how to bind
the mouse wheel to scroll the Listbox.
$lf1 = $mw->Labelframe(...
$lb1 = $lf1->Scrolled('Listbox',
I've tried using Widget.pm's YscrollBind, YMouseWheelBind, MouseWheelBind,
and even manually adding an event and binding it to yview/scroll.
Can someone insert a couple of lines of code below that works to bind
the mouse wheel on Win32 to scroll the Listbox content vertically ?
TIA, Bill
Test template:
#!perl --
use strict;
use warnings;
use Tk;
my $mw = new MainWindow (-title => "Test ($$)");
my $lf1 = $mw->Labelframe(-text => 'Test MW Bind',
-relief => 'ridge')->pack(-fill => 'both', -expand => 1
);
my $lb1 = $lf1->Scrolled('Listbox', -scrollbars => 'ose',
-width => 40, -height => 4, -selectmode => 'extended')->pack(
-side => 'bottom', -fill => 'both', -expand => 1
);
# bind y scroll to mouse wheel here
# fill with some data for testing
$lb1->insert('end', 'Testing 1234567890 Testing 1234567890') for (1 .. 20);
MainLoop ();
__END__
the mouse wheel to scroll the Listbox.
$lf1 = $mw->Labelframe(...
$lb1 = $lf1->Scrolled('Listbox',
I've tried using Widget.pm's YscrollBind, YMouseWheelBind, MouseWheelBind,
and even manually adding an event and binding it to yview/scroll.
Can someone insert a couple of lines of code below that works to bind
the mouse wheel on Win32 to scroll the Listbox content vertically ?
TIA, Bill
Test template:
#!perl --
use strict;
use warnings;
use Tk;
my $mw = new MainWindow (-title => "Test ($$)");
my $lf1 = $mw->Labelframe(-text => 'Test MW Bind',
-relief => 'ridge')->pack(-fill => 'both', -expand => 1
);
my $lb1 = $lf1->Scrolled('Listbox', -scrollbars => 'ose',
-width => 40, -height => 4, -selectmode => 'extended')->pack(
-side => 'bottom', -fill => 'both', -expand => 1
);
# bind y scroll to mouse wheel here
# fill with some data for testing
$lb1->insert('end', 'Testing 1234567890 Testing 1234567890') for (1 .. 20);
MainLoop ();
__END__