Notalib / nativescript-webview-ext

Nativescript plugin with extended WebView functionality
Apache License 2.0
76 stars 37 forks source link

Prevent user interactions #55

Closed kriefsacha closed 4 years ago

kriefsacha commented 4 years ago

Hi,

We are on Nativescript Angular 6.2 with web view 6.0.0-alpha.2.

We need sometimes to prevent the user to interact with the webview , disable it.

We tried isEnabled, isUserInteractionEnabled , touch-action : none , pointer-events:none

Nothing works.

I wanted to know if you know how can we do that ? Display the webview but the user can't interact with it.

Thank you !

kriefsacha commented 4 years ago

Someone ? It's quite urgent ..

m-abs commented 4 years ago

Hi @kriefsacha,

Not a use-case we've thought of.

Without having tested it:

public onWebViewLoaded(evt) {
  const webView = evt.object;

  if (webView.android) {
    webView.android.setOnTouchListener(new android.view.View.OnTouchListener({ onTouch() { return true; }}));
  } else if (webView.ios) {
    webView.ios.userInteractionEnabled = false;
    webView.ios.scrollView.userInteractionEnabled = false;
  }
}
kriefsacha commented 4 years ago

Tested on Android, seems to work as we want !

I will test it on Ios, and keep you in touch.

Thanks man !

m-abs commented 4 years ago

Hey @kriefsacha

I've added support for ´isEnabled="false"` in the latest alpha

farhankassam2 commented 3 years ago

I tried using the isEnabled prop in a <WebView ... /> component and set it to "false", but the street view I display from within the web view is still interactive. I am displaying the Webview in iOS. For iOS, I also tried setting isUserInteractionEnabled to false the way it has been suggested in other Github posts but that does not work either.

So how should I disable user interaction in the WebView or even within an <iFrame that I render inside of the web view? Some help will be greatly appreciated. Thanks.