Skip to content

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

@zhaojiewen

Description

@zhaojiewen

“透明组件” 只是表述的不可见组件,容易引起误解!适当的表述可以是:命中测试失败(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 //放开此行注释后可以"点透"
)
],
),

Activity

ghost

ghost commented on Jan 2, 2020

@ghost

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      No branches or pull requests

        Participants

        @zhaojiewen

        Issue actions

          关于第八章第一节 “原始指针事件 ” 中“透明组件”概念模糊 · Issue #362 · flutterchina/flutter-in-action