Skip to content

关于第八章第一节 “原始指针事件 ” 中“透明组件”概念模糊 #362

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

Open
zhaojiewen opened this issue Dec 30, 2019 · 1 comment

Comments

@zhaojiewen
Copy link

“透明组件” 只是表述的不可见组件,容易引起误解!适当的表述可以是:命中测试失败(hitTest)的组件,如果透明组件hitTest成功,translucent 与 opaque 的特性将无效!比如使用#DecoratedBox# 来包装子组件,设置透明度为0,也是不可见,反例如下,修改此节translucent 测试代码为:
Stack(
children: [
Listener(
child: ConstrainedBox(
constraints: BoxConstraints.tight(Size(300.0, 200.0)),
child: DecoratedBox(
decoration: BoxDecoration(
color: Color.fromARGB(255, 255, 1, 1))),
),
onPointerDown: (event) => print("down0"),
// behavior: HitTestBehavior.opaque,
),
Listener(
child: ConstrainedBox(
constraints:
BoxConstraints.tight(Size(200.0, 100.0)),
child: DecoratedBox(
decoration: BoxDecoration(
color: Color.fromARGB(0, 0, 0, 0)),
child: Center(
child: Text("左上角200*100范围内非文本区域点击"),
),
)),
onPointerDown: (event) => print("down1"),
behavior: HitTestBehavior.translucent //放开此行注释后可以"点透"
)
],
),

@ghost
Copy link

ghost commented Jan 2, 2020

赞同,我也是在这里纠结了很久。

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