Titanium Community Questions & Answer Archive

We felt that 6+ years of knowledge should not die so this is the Titanium Community Questions & Answer Archive

Text selection in WebView

How to disable the webview context menu (copy and define) while enabling text selection?

I have tried different combination of css property. Seems the context menu can only be disabled with the following combination:

-webkit-touch-callout:none;

-webkit-user-select:none;

If set -webkit-user-select to "text", the callout is enabled even -webkit-touch-callout is set to "none"

I just need the text highlight behavior but not the "copy" popover menu in browser.

Anyone has a clue?

P.S. I am testing my app on iPad simulator and device.

— asked February 1st 2012 by Bowie Poon
  • context menu
  • text highlight
  • text selection
  • webkit
  • webview
0 Comments

3 Answers

  • did you manage to find answer for this? i am also looking to solve the same problem. please let me know.

    — answered June 25th 2012 by ganesh Ramaswamy
    permalink
    1 Comment
    • No. The highlight must trigger the popover menu in Safari.

      — commented June 25th 2012 by Bowie Poon
  • use this—–>

    webview.addEventListener('longpress', function(e) {
    return false;
    });

    webview.addEventListener('longclick', function(e) {
    return false;
    });

    — answered October 9th 2012 by Arun Shejul
    permalink
    2 Comments
    • Will that disable text selection at the same time?

      — commented October 9th 2012 by Bowie Poon
    • yes i was done this for android and for iphone you can try this——>add css

      • {
        -webkit-touch-callout: none;
        -webkit-user-select: none; / Disable selection/Copy of UIWebView /
        }

      — commented October 10th 2012 by Arun Shejul
  • yes i am sure this will help you for only android and for iphone you can add this css ——>

    • {
      -webkit-touch-callout: none;
      -webkit-user-select: none; / Disable selection/Copy of UIWebView /
      }
    — answered October 10th 2012 by Arun Shejul
    permalink
    1 Comment
    • As stated in my question, i know the css setting can disable the popover menu but I want to enable user selection at the same time.

      — commented October 10th 2012 by Bowie Poon
The ownership of individual contributions to this community generated content is retained by the authors of their contributions.
All trademarks remain the property of the respective owner.