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

WebView's text selection handles are not showing on Android #24584

Open
amirh opened this issue Nov 20, 2018 · 7 comments

Comments

@amirh
Copy link
Contributor

@amirh amirh commented Nov 20, 2018

It seems that the selection handles are implemented as a PopupWindow, seems like we don't support these well enough.

@romatroskin

This comment has been minimized.

Copy link

@romatroskin romatroskin commented Dec 30, 2018

can we rely on this issue to be fixed soon? it's really important for us :(

@amirh amirh added this to the Near-term Goals milestone Jan 10, 2019
@filipenanclarez

This comment has been minimized.

Copy link

@filipenanclarez filipenanclarez commented Apr 11, 2019

Without this, we can't made apps to read ebooks.

Please pay attention to this issue.

@bojie-liu

This comment has been minimized.

Copy link

@bojie-liu bojie-liu commented Aug 10, 2019

Is there any progress for this issue? I studied the source code and found something.
PopupWindows in (Android) WebView requires WebView's hasWindowFocus as true to update its position and drawing state. However the Window the WebView attach to is set to FLAG_NOT_FOCUSABLE in SingleViewPresentation. This NOT_FOCUSABLE commit(42bd86d) is a workaround fix to another keyboard issue according to the commit message.
As a quick verification if focus on window could make selection handles shown, I tried removing FLAG_NOT_FOCUSABLE for WebView and setLocalFocus for the FlutterView which leads to both Window are focused in Android framework. And it works. Although keyboard in WebView is not shown again. It seems I have to dig deeper to understand what's going on there.

@amirh

This comment has been minimized.

Copy link
Contributor Author

@amirh amirh commented Aug 13, 2019

@bojie-liu thanks for the info, this is really helpful! Can you point to the PopupWindow code that checks for the focus?

Given your findings, it may make sense to override hasWindowFocus (the plugin subclasses WebView already) and return whether the FlutterView's window is focused.

@conghaonet

This comment has been minimized.

Copy link

@conghaonet conghaonet commented Nov 6, 2019

it is the same with webview_flutter 0.3.15+1

@bojie-liu

This comment has been minimized.

Copy link

@bojie-liu bojie-liu commented Nov 9, 2019

Sorry for taking two months to reply. It seems I got no notification from user center, although already subscribed. May be I should read some github manuals later.

The PopupWindow related code is in PopupTouchHandleDrawable.java (link is as follows). The updateVisibility() will check if isShowingAllowed() and setVisibility() for current drawable. And one of conditions in isShowingAllowed() is mFocused which was set to containerView.hasWindowFocus() initially. In my experiment, the false mFocused is the cause of invisibility of the handles.
https://cs.chromium.org/chromium/src/android_webview/java/src/org/chromium/android_webview/PopupTouchHandleDrawable.java?rcl=cf0b4429b5815c4a2bc753e42159f9dc2cb90037&l=443
@amirh

@Hixie

This comment has been minimized.

Copy link
Contributor

@Hixie Hixie commented Nov 27, 2019

@amirh Can we have this assigned and a conservative milestone specified? Thanks!

@amirh amirh modified the milestones: Near-term Goals, June 2020 Nov 27, 2019
@amirh amirh self-assigned this Nov 27, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.