Hello Monks,

I have an issue with mouse wheel scrolling when I have frame created with the Scrolled method, and that frame contains listboxes. I can scroll the toplevel frame just fine with the mouse wheel when it is the focus and mouse wheel scrolling has been enabled.

However, when I click on a listbox (making it active) and scroll through it with the mouse wheel, the toplevel frame also scrolls. How can I disable the mouse wheel scrolling in the toplevel frame when the focus is in a listbox? Here is a simple example that shows the issue and thank you in advance:

use Tk; use Tk::BrowseEntry; use Tk::Pane; use Term::ReadKey; use strict; my ($mw,$topframe,$font,$row,$i,$who); my (@frame,@list,@label); my (%var); $mw = MainWindow->new(); $mw->title("Test GUI"); $mw->bind('<KeyPress-Return>', sub{shift->focusNext}); $mw->geometry('1000x300+400+0'); $topframe = $mw->Scrolled('Frame', -scrollbars => 'e',-height => 1000) +->pack(); $mw->bind('all','<4>',=>sub{$topframe->yview('scroll',3,'units')}); $mw->bind('all','<5>',=>sub{$topframe->yview('scroll',3,'units')}); $font = "-adobe-times-bold-r-normal--20-100-75-75-p-p-56-iso8859-1"; $row = 1; for ($i =0; $i < 100; $i++) { $frame[$i] = $topframe->Frame(-borderwidth => '1', -relief => +'groove'); $list[$i] = $frame[$i]->BrowseEntry(-variable => \$var{$i}, -takefocus => 0, -foreground => 'black', -disabledforeground => 'black', -highlightcolor => 'green', -font => $font, -width => 50, -state => 'readonly') ->pack(-side => "left", +-padx => "5"); $label[$i] = $frame[$i]->Label(-text => $i, -anchor => 'w', -takefocus => 0, -foreground => 'black', -font => $font, -width => 50, -height => 1) ->pack(-side => "right", -padx +=> 5); $frame[$i]->grid(-row => ++$row, -column => 1, -sticky => 'e', + -padx => 5); $list[$i]->insert('end', (1..100)); } MainLoop();

In reply to Perl Tk issue with mouse wheel scrolling by cygnus

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.