Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QtWebEngine
  4. How to disable user-text-selection without using CSS Stylesheet?
Forum Updated to NodeBB v4.3 + New Features

How to disable user-text-selection without using CSS Stylesheet?

Scheduled Pinned Locked Moved Unsolved QtWebEngine
4 Posts 2 Posters 1.5k Views 2 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    SteKo_dev
    wrote on 29 Mar 2018, 08:32 last edited by
    #1

    I am using the QtWebengine in Version 5.9.4 based in Chromium 56.

    I've tried to find an option to disable the text selection on html pages in the source code of my QT Project, but I did not found any option to do this.

    I know the option, using CSS Stylesheets, but this is no possible solution for my project because the customers often implements this option not in their sourcecode stylesheets and don't want to change it afterwards.

    Is their any possibility to change this behavior in the QtWebEngine Framework or do I need to find a solution on the Chromium based source code?

    R 1 Reply Last reply 29 Mar 2018, 10:27
    0
    • S SteKo_dev
      29 Mar 2018, 08:32

      I am using the QtWebengine in Version 5.9.4 based in Chromium 56.

      I've tried to find an option to disable the text selection on html pages in the source code of my QT Project, but I did not found any option to do this.

      I know the option, using CSS Stylesheets, but this is no possible solution for my project because the customers often implements this option not in their sourcecode stylesheets and don't want to change it afterwards.

      Is their any possibility to change this behavior in the QtWebEngine Framework or do I need to find a solution on the Chromium based source code?

      R Offline
      R Offline
      raven-worx
      Moderators
      wrote on 29 Mar 2018, 10:27 last edited by
      #2

      @SteKo_dev
      you can still include a default stylesheet (transparent for each user) - independently for the page loaded.
      See this example.

      --- SUPPORT REQUESTS VIA CHAT WILL BE IGNORED ---
      If you have a question please use the forum so others can benefit from the solution in the future

      1 Reply Last reply
      0
      • S Offline
        S Offline
        SteKo_dev
        wrote on 29 Mar 2018, 10:50 last edited by
        #3

        With your help,I found a solution to do that, but in my opinion its really dirty to inject code to a customer html document.

        It works for the first moment, but I’d like to find a solution without injecting code to a customer page.

        See code below.

        WebEngineView.runJavaScript("var head = document.head;" +
                              "var node= document.createElement('style');" +
                              "var textnode = document.createTextNode('body {-webkit-user-select: none !important;}');" +
                              "node.appendChild(textnode);head.appendChild(node);"
                             ,function(){/*Empty function for callback*/})
        

        Is there any possibility to change it in the chromium based source code by default ?

        R 1 Reply Last reply 29 Mar 2018, 10:57
        0
        • S SteKo_dev
          29 Mar 2018, 10:50

          With your help,I found a solution to do that, but in my opinion its really dirty to inject code to a customer html document.

          It works for the first moment, but I’d like to find a solution without injecting code to a customer page.

          See code below.

          WebEngineView.runJavaScript("var head = document.head;" +
                                "var node= document.createElement('style');" +
                                "var textnode = document.createTextNode('body {-webkit-user-select: none !important;}');" +
                                "node.appendChild(textnode);head.appendChild(node);"
                               ,function(){/*Empty function for callback*/})
          

          Is there any possibility to change it in the chromium based source code by default ?

          R Offline
          R Offline
          raven-worx
          Moderators
          wrote on 29 Mar 2018, 10:57 last edited by
          #4

          @SteKo_dev said in How to disable user-text-selection without using CSS Stylesheet?:

          Is there any possibility to change it in the chromium based source code by default ?

          i would say THAT is the dirty way actually. You would have to make the change for every release?!
          I don't see why the injection should be dirty in your opinion. Thats actually pretty normal in Web 2.0 to dynamically inject content into a webpage.

          --- SUPPORT REQUESTS VIA CHAT WILL BE IGNORED ---
          If you have a question please use the forum so others can benefit from the solution in the future

          1 Reply Last reply
          0

          1/4

          29 Mar 2018, 08:32

          • Login

          • Login or register to search.
          1 out of 4
          • First post
            1/4
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • Users
          • Groups
          • Search
          • Get Qt Extensions
          • Unsolved