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

Flutter [onTap] [onPressed] events don't work on [Widget]s placed on-top of [NativeView]s #5

Open
cacard opened this issue Mar 28, 2022 · 2 comments

Comments

@cacard
Copy link

cacard commented Mar 28, 2022

I want put a button on NativeView, and add a onTap event, but the event not work when I click the button.

@alexmercerind
Copy link
Owner

I have planned to implement it, but other things need more stability before going ahead.

@alexmercerind alexmercerind changed the title ontap event not work Flutter [onTap] [onPressed] events don't work on [Widget]s placed on-top of [NativeView]s Mar 28, 2022
@alexmercerind
Copy link
Owner

alexmercerind commented Mar 28, 2022

Regardless, thanks for the report. Feel free to open & document more issues if you discover.

This will require few changes on the native side, currently when passing HitTest.translucent, the window becomes "click-through" & mouse clicks are sent to the NativeView underneath. And once the mouse cursor moves outside of the area (NativeView's area), it sends back event to make window clickable again.
I think an API that allows to wrap the widgets (which should are meant to be placed on-top of the NativeView) should be good.

Stack(
  children: [
    LayoutBuilder(
      /// Create a [NativeView].
      builder: (context, constraints) => NativeView(
        /// Pass [NativeViewController] to render the window.
        controller: controller,
        width: constraints.maxWidth,
        height: constraints.maxHeight,
      ),
    ),
    Padding(
      padding: const EdgeInsets.all(16.0),
        /// I had something like this in mind.
        child: NativeViewInteractionInterceptArea(
          child: FloatingActionButton(
            onPressed: () {},
            child: const Icon(Icons.edit),
          ),
        ),
      ),
    ),
  ],
),

Apart from above, we have another issue which causes `NativeView` to leak with `HitTest.translucent`'s intractability to leak through the title-bar.

Is it possible to send events/clicks programmatically in your case (since current click-through approach doesn't seem that great in my opinion)?

If anyone has any opinions, feel free to share.
Thanks.

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

2 participants