Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

How to bind mouse wheel on Win32 Tk?

9 views
Skip to first unread message

$Bill

unread,
Oct 1, 2018, 8:02:14 PM10/1/18
to
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__

$Bill

unread,
Oct 2, 2018, 7:47:14 PM10/2/18
to
On 10-01-18 17:02, $Bill wrote:
> Given a frame with a Listbox in it, I can't figure out how to bind
> the mouse wheel to scroll the Listbox.

Turns out (with a lot of digging and some luck) that it's already
bound, but you have to hit the tab key to get it to focus on the
Listbox to get it to work.


0 new messages