• How to bind mouse wheel on Win32 Tk?

    From $Bill@21:1/5 to All on Mon Oct 1 17:02:13 2018
    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__

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From $Bill@21:1/5 to All on Tue Oct 2 16:47:12 2018
    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.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)