Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 25 additions & 16 deletions lib/web_ui/lib/src/engine/pointer_binding.dart
Original file line number Diff line number Diff line change
Expand Up @@ -290,6 +290,29 @@ mixin _WheelEventListenerMixin on _BaseAdapter {
);
}

void _handleWheelEvent(
html.Event e, void Function(Iterable<ui.PointerData>) sink) {
assert(e is html.WheelEvent);
final html.WheelEvent event = e as html.WheelEvent;
if (_debugLogPointerEvents) {
print(event.type);
}
if (event.getModifierState('Control') &&
operatingSystem != OperatingSystem.macOs &&
operatingSystem != OperatingSystem.iOs) {
// Ignore Control+wheel events since the default handler
// will change browser zoom level instead of scrolling.
// The exception is MacOs where Control+wheel will still scroll and zoom
// is not implemented.
return;
}
_callback(_convertWheelEventToPointerData(event));
// Prevent default so mouse wheel event doesn't get converted to
// a scroll event that semantic nodes would process.
//
event.preventDefault();
}

/// For browsers that report delta line instead of pixels such as FireFox
/// compute line height using the default font size.
///
Expand Down Expand Up @@ -514,14 +537,7 @@ class _PointerAdapter extends _BaseAdapter with _WheelEventListenerMixin {
});

_addWheelEventListener((html.Event event) {
assert(event is html.WheelEvent);
if (_debugLogPointerEvents) {
print(event.type);
}
_callback(_convertWheelEventToPointerData(event as html.WheelEvent));
// Prevent default so mouse wheel event doesn't get converted to
// a scroll event that semantic nodes would process.
event.preventDefault();
_handleWheelEvent(event, _callback);
});
}

Expand Down Expand Up @@ -793,14 +809,7 @@ class _MouseAdapter extends _BaseAdapter with _WheelEventListenerMixin {
}, acceptOutsideGlasspane: true);

_addWheelEventListener((html.Event event) {
assert(event is html.WheelEvent);
if (_debugLogPointerEvents) {
print(event.type);
}
_callback(_convertWheelEventToPointerData(event as html.WheelEvent));
// Prevent default so mouse wheel event doesn't get converted to
// a scroll event that semantic nodes would process.
event.preventDefault();
_handleWheelEvent(event, _callback);
});
}

Expand Down