Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

第八章 8.3.5 HitTestBehavior 中 PointerDownEvent组件,其中一行代码bool hitTestSelf(Offset position) =>true; //始终通过命中测试,我将hitTestSelf返值改为false,为什么也能命中测试 #201

Open
ynahauH opened this issue Aug 14, 2023 · 0 comments

Comments

@ynahauH
Copy link

ynahauH commented Aug 14, 2023

class RenderPointerDownListener extends RenderProxyBox {
PointerDownEventListener? onPointerDown;

@OverRide
bool hitTestSelf(Offset position) => true; //始终通过命中测试

@OverRide
void handleEvent(PointerEvent event, covariant HitTestEntry entry) {
//事件分发时处理事件
if (event is PointerDownEvent) onPointerDown?.call(event);
}
}

class PointerDownListenerRoute extends StatelessWidget {
const PointerDownListenerRoute({Key? key}) : super(key: key);

@OverRide
Widget build(BuildContext context) {
return PointerDownListener(
child: const Text('Click me'),
onPointerDown: (e) => print('down'),
);
}
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant