Commit 3d7961a7 authored by Christian Fibich's avatar Christian Fibich Committed by Stefan Tauner
Browse files

Search for nearest ancestor widget when scrolling with mousewheel

parent 061d8756
......@@ -189,27 +189,31 @@ sub _wheel_handler {
my ($event_widget, $val, $mw) = @_;
for (my $index = 0; $index < @{$mw->{'scrollable_widgets'}}; $index++) {
my $widget_to_scroll = @{$mw->{'scrollable_widgets'}}[$index];
# remove already deleted widgets from list
unless (Tk::Exists($widget_to_scroll)) {
delete @{$mw->{'scrollable_widgets'}}[$index];
next;
}
# only scroll if visible
next if (!$widget_to_scroll->ismapped());
my $scrolled = $widget_to_scroll->Subwidget('scrolled');
my $container;
for ($container = $event_widget;
defined $container && $container != $widget_to_scroll;
$container = $container->parent) {}
next if (!defined $container);
if ($^O eq "MSWin32") {
$scrolled->yview(scroll=>(-$val/120)*SCROLL,'units');
} else {
$scrolled->yview(scroll=>$val*SCROLL,'units');
my $container;
# search through hierarchy of widget causing the event
# for the nearest ancestor in the list of widgets to be scrolled
for ($container = $event_widget; defined $container; $container = $container->parent) {
# search the list of the widgets to be scrolled
for (my $index = 0; $index < @{$mw->{'scrollable_widgets'}}; $index++) {
my $widget_to_scroll = @{$mw->{'scrollable_widgets'}}[$index];
# remove already deleted widgets from list
unless (Tk::Exists($widget_to_scroll)) {
delete @{$mw->{'scrollable_widgets'}}[$index];
next;
}
next if $container != @{$mw->{'scrollable_widgets'}}[$index];
my $scrolled = $widget_to_scroll->Subwidget('scrolled');
if ($^O eq "MSWin32") {
$scrolled->yview(scroll=>(-$val/120)*SCROLL,'units');
} else {
$scrolled->yview(scroll=>$val*SCROLL,'units');
}
goto END;
}
}
END:
return;
}
1;
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment