-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
Android: no text selection possible with useHybridComposition and long webview #722
Comments
The problem is related to the |
Thank you very much for your feedback, but the text selection works when I either do not use the hybrid mode or when I have a webpage that is not too long. As I wrote above, I am unsure if the length of the webview is really the only criteria. Since the text selection works in some case, I doubt that the |
Unfortunately, I'm not able to reproduce your problem. |
Thanks again, I will try to come up with a better reproduction case and will file a new bug when I have it. Thanks and keep up the good work! |
Here is an example with your code and without import 'dart:async';
import 'dart:io';
import 'package:flutter/material.dart';
import 'package:flutter_inappwebview/flutter_inappwebview.dart';
Future main() async {
WidgetsFlutterBinding.ensureInitialized();
if (Platform.isAndroid) {
await AndroidInAppWebViewController.setWebContentsDebuggingEnabled(true);
}
runApp(MaterialApp(
home: MyApp()
));
}
class MyApp extends StatefulWidget {
@override
_MyAppState createState() => new _MyAppState();
}
class _MyAppState extends State<MyApp> {
@override
void initState() {
super.initState();
}
@override
void dispose() {
super.dispose();
}
double? webviewHeight;
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text('Select Text'),
),
body: Column(
children: [
SizedBox(
height: webviewHeight ?? MediaQuery.of(context).size.height,
child: InAppWebView(
initialUrlRequest: URLRequest(url: Uri.parse("https://github.com/pichillilorenzo/flutter_inappwebview/pulls")),
initialOptions: InAppWebViewGroupOptions(
crossPlatform: InAppWebViewOptions(
useShouldOverrideUrlLoading: true,
verticalScrollBarEnabled: false,
),
android: AndroidInAppWebViewOptions(
useWideViewPort: false,
loadWithOverviewMode: true,
useHybridComposition: true,
),
),
onLoadStop: (controller, url) async {
int? scrollHeight = await controller.evaluateJavascript(
source: 'document.body.scrollHeight');
if (scrollHeight != null) {
setState(() {
webviewHeight = scrollHeight + 30.0;
});
}
},
),
),
],
),
);
}
} Here is the screen recording: device-2021-03-19-123045.mp4Setting
|
Little bit of an old thread but this is easily fixable with gestureRecognizers: {
Factory<VerticalDragGestureRecognizer>(() => VerticalDragGestureRecognizer()),
Factory<LongPressGestureRecognizer>(() => LongPressGestureRecognizer()),
}, does the trick. VerticalDrag for scrolling support and LongPress for text selection support. |
Very cool, I can confirm this works fine! In my case I do not use the gestureRecognizers: {
Factory<LongPressGestureRecognizer>(() => LongPressGestureRecognizer()),
Factory<ScaleGestureRecognizer>(() => ScaleGestureRecognizer()),
}, So many thanks @tneotia - you made someone very happy :-) |
To use MimeMessageViewer in a ScrollView, the adjustHeight option needs to be set to true. However, in that case the text selection using the long press gesture is not working anymore. This is now fixed by specifying gestureRecognizers. Compare pichillilorenzo/flutter_inappwebview#722 for details.
add gestureRecognizers helps,thank you |
This thread has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar issue, please open a new bug and a minimal reproduction of the issue. |
Environment
Device information:
• BlackView/A80Pro (mobile) A80DK017EEA0070119
• Pixel 2 (emulator) sdk gphone x86 (mobile)
Description
When I enable the hybrid mode with
AndroidInAppWebViewOptions( useHybridComposition: true )
, then I cannot select text when setting the webview's height at the same time.In a simple reproduction project I can reduce the height to a seemingly device specific value and then I can select text again. In a more complex setup I was not able to get selection to work by reducing the height, so the height might not be the deciding factor.
Expected behavior:
Text selection via the long press gesture should still be possible.
Current behavior:
Text selection does not work in InAppWebView from a certain height onward.
Steps to reproduce
InAppWebView
in aSizedBox
and let it load a long webpage.document.body.scrollHeight
as this seems to work better thangetContentHeight()
) and apply the measured height in the SizedBoxSample code (without null-safety):
Possibly related to #704
The text was updated successfully, but these errors were encountered: