feat: add FocusNode to ThermionListenerWidget
This commit is contained in:
@@ -26,6 +26,8 @@ class ThermionListenerWidget extends StatefulWidget {
|
|||||||
///
|
///
|
||||||
final Widget? child;
|
final Widget? child;
|
||||||
|
|
||||||
|
final FocusNode? focusNode;
|
||||||
|
|
||||||
///
|
///
|
||||||
/// The handler to use for interpreting gestures/pointer movements.
|
/// The handler to use for interpreting gestures/pointer movements.
|
||||||
///
|
///
|
||||||
@@ -34,6 +36,7 @@ class ThermionListenerWidget extends StatefulWidget {
|
|||||||
const ThermionListenerWidget({
|
const ThermionListenerWidget({
|
||||||
Key? key,
|
Key? key,
|
||||||
required this.inputHandler,
|
required this.inputHandler,
|
||||||
|
this.focusNode,
|
||||||
this.child,
|
this.child,
|
||||||
}) : super(key: key);
|
}) : super(key: key);
|
||||||
|
|
||||||
@@ -81,7 +84,10 @@ class _ThermionListenerWidgetState extends State<ThermionListenerWidget> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Widget _desktop(double pixelRatio) {
|
Widget _desktop(double pixelRatio) {
|
||||||
return Listener(
|
return Focus(
|
||||||
|
focusNode: widget.focusNode,
|
||||||
|
child:Listener(
|
||||||
|
|
||||||
onPointerHover: (event) {
|
onPointerHover: (event) {
|
||||||
widget.inputHandler.onPointerHover(
|
widget.inputHandler.onPointerHover(
|
||||||
event.localPosition.toVector2() * pixelRatio,
|
event.localPosition.toVector2() * pixelRatio,
|
||||||
@@ -98,6 +104,7 @@ class _ThermionListenerWidgetState extends State<ThermionListenerWidget> {
|
|||||||
throw Exception("TODO - is this a pinch zoom on laptop trackpad?");
|
throw Exception("TODO - is this a pinch zoom on laptop trackpad?");
|
||||||
},
|
},
|
||||||
onPointerDown: (d) {
|
onPointerDown: (d) {
|
||||||
|
widget.focusNode?.requestFocus();
|
||||||
widget.inputHandler.onPointerDown(
|
widget.inputHandler.onPointerDown(
|
||||||
d.localPosition.toVector2() * pixelRatio,
|
d.localPosition.toVector2() * pixelRatio,
|
||||||
d.buttons & kMiddleMouseButton != 0);
|
d.buttons & kMiddleMouseButton != 0);
|
||||||
@@ -109,7 +116,7 @@ class _ThermionListenerWidgetState extends State<ThermionListenerWidget> {
|
|||||||
onPointerUp: (d) =>
|
onPointerUp: (d) =>
|
||||||
widget.inputHandler.onPointerUp(d.buttons & kMiddleMouseButton != 0),
|
widget.inputHandler.onPointerUp(d.buttons & kMiddleMouseButton != 0),
|
||||||
child: widget.child,
|
child: widget.child,
|
||||||
);
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
Widget _mobile(double pixelRatio) {
|
Widget _mobile(double pixelRatio) {
|
||||||
|
|||||||
Reference in New Issue
Block a user