Zucan has asked for the wisdom of the Perl Monks concerning the following question:

I am using ActivePerl 5.12.2 on Windows 7. I noticed that when I attach a scrollbar to either a listbox or a tree that the mouse wheel will allow me to scroll down the list, but not allow me to scroll up the list.

Here is a sample program using a listbox:

#!/usr/bin/perl -w use strict; use Tkx; my $mw = Tkx::widget->new("."); my $lb = $mw->new_tk__listbox(-height => 10); $lb->insert("end", 1..100); $lb->g_grid(-column => 0, -row => 0); my $sb = $mw->new_ttk__scrollbar(-orient => 'vertical', -command => [$ +lb, 'yview']); $sb->g_grid(-column => 1, -row => 0, -sticky => "ns"); $lb->configure(-yscrollcommand => [$sb, "set"]); Tkx::MainLoop();

I don't think I am doing anything wrong here, but thought I would ask the Monks for their thoughts. I find that I am now looking at binding MouseWheel events to the listbox and spending a lot more time on this than may even be necessary. Can somebody confirm the behavior with the script above?

Thanks!

Replies are listed 'Best First'.
Re: Perl::Tkx Mousewheel Scrolling
by Anonymous Monk on Jan 09, 2011 at 02:10 UTC
    Once I give focus to the list box (not the listbox scrollbar), scrolling works both ways for me
    $ pmvers Tkx Tcl Tkx: 1.07 Tcl: 0.97
      What OS are you running on? Is it Windows? Thanks for the reply!
        strawberry perl v5.10.0 built for MSWin32-x86-multi-thread
Re: Perl::Tkx Mousewheel Scrolling
by Zucan (Beadle) on Jan 09, 2011 at 02:16 UTC

    I simplified the code a bit more by using Tkx::Scrolled, to see if anything changed. Since the Scrolled widget really uses the same stuff behind the scenes, I didn't expect anything different:

    #!/usr/bin/perl -w use strict; use Tkx; use Tkx::Scrolled; my $mw = Tkx::widget->new("."); my $lb = $mw->new_tkx_Scrolled("listbox", -scrollbars => "e", -height +=> 10); $lb->insert("end", 1..100); $lb->g_grid(-column => 0, -row => 0); Tkx::MainLoop();

    Basically, I can scroll up and down with the keyboard (arrow keys and page up/down) and the mouse (if I grab the scrollbar with the mouse and move it up and down). I can also scroll down if I roll the mouse wheel downwards, but I cannot scroll up by rolling the mouse wheel upwards.

    I am tempted to bring up a Linux VM and seeing what this code does outside of Windows. However, that means bringing up a new VM, installing Tcl/Tk, and all the associated Tkx perl modules. So... maybe not tonight.