flutter_native_view icon indicating copy to clipboard operation
flutter_native_view copied to clipboard

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

Open cacard opened this issue 3 years ago • 2 comments

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

cacard avatar Mar 28 '22 01:03 cacard

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

alexmercerind avatar Mar 28 '22 07:03 alexmercerind

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.

alexmercerind avatar Mar 28 '22 17:03 alexmercerind