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
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |