add await to inputHandler calls in ThermionListenerWidget

This commit is contained in:
Nick Fisher
2025-05-15 16:55:01 +08:00
parent bdba92c842
commit fdd3853121

View File

@@ -19,6 +19,7 @@ extension OffsetExtension on Offset {
/// [InputHandler]. /// [InputHandler].
/// ///
class ThermionListenerWidget extends StatefulWidget { class ThermionListenerWidget extends StatefulWidget {
/// The content to display below the gesture detector/listener widget. /// The content to display below the gesture detector/listener widget.
/// This will usually be a ThermionWidget (so you can navigate by directly /// This will usually be a ThermionWidget (so you can navigate by directly
/// interacting with the viewport), but this is not necessary. It is equally /// interacting with the viewport), but this is not necessary. It is equally
@@ -106,16 +107,16 @@ class _ThermionListenerWidgetState extends State<ThermionListenerWidget> {
return Focus( return Focus(
focusNode: widget.focusNode, focusNode: widget.focusNode,
child: Listener( child: Listener(
onPointerHover: (event) { onPointerHover: (event) async {
widget.inputHandler.handle(MouseEvent( await widget.inputHandler.handle(MouseEvent(
MouseEventType.hover, MouseEventType.hover,
_mouseButtonFromEvent(event), _mouseButtonFromEvent(event),
event.localPosition.toVector2() * pixelRatio, event.localPosition.toVector2() * pixelRatio,
event.delta.toVector2() * pixelRatio)); event.delta.toVector2() * pixelRatio));
}, },
onPointerSignal: (PointerSignalEvent pointerSignal) { onPointerSignal: (PointerSignalEvent pointerSignal) async {
if (pointerSignal is PointerScrollEvent) { if (pointerSignal is PointerScrollEvent) {
widget.inputHandler.handle(ScrollEvent( await widget.inputHandler.handle(ScrollEvent(
localPosition: localPosition:
pointerSignal.localPosition.toVector2() * pixelRatio, pointerSignal.localPosition.toVector2() * pixelRatio,
delta: pointerSignal.scrollDelta.dy * pixelRatio)); delta: pointerSignal.scrollDelta.dy * pixelRatio));
@@ -124,10 +125,10 @@ class _ThermionListenerWidgetState extends State<ThermionListenerWidget> {
onPointerPanZoomStart: (pzs) { onPointerPanZoomStart: (pzs) {
throw Exception("TODO - is this a pinch zoom on laptop trackpad?"); throw Exception("TODO - is this a pinch zoom on laptop trackpad?");
}, },
onPointerDown: (event) { onPointerDown: (event) async {
widget.focusNode?.requestFocus(); widget.focusNode?.requestFocus();
widget.inputHandler.handle(MouseEvent( await widget.inputHandler.handle(MouseEvent(
MouseEventType.buttonDown, MouseEventType.buttonDown,
_mouseButtonFromEvent(event), _mouseButtonFromEvent(event),
event.localPosition.toVector2() * pixelRatio, event.localPosition.toVector2() * pixelRatio,