How can I disable selection property on Qwebview
-
I had the same problem some days ago. I couldn't find a nice way to fix it on the QWebPage side, so I fixed it on the html side.
Try to set the CSS property:
@-webkit-user-select:none;@ -
We don't yet have a convenient API for interaction with touch screen. You will have to do some of the work yourself to avoid selection while having a nice touch interface.
I suggest you to look at "http://gitorious.org/yberbrowser":http://gitorious.org/yberbrowser and
"http://gitorious.org/light":http://gitorious.org/light which are handling touch input quite nicely. -
Hi All, This does not seems to fix the problem, as I want to disable the selection only on QWebView text and graphics, I have other control like map where I need to have mouse clicked and drag enable so looks like I need to make some changes in the qwebkit, can any one please give me some hint what should I looking for?
-
[quote author="mprakash" date="1287458087"]Hi All, This does not seems to fix the problem, as I want to disable the selection only on QWebView text and graphics, I have other control like map where I need to have mouse clicked and drag enable so looks like I need to make some changes in the qwebkit, can any one please give me some hint what should I looking for?[/quote]
In that case, you will have to wait a little I am afraid. There is a bug report open to add such a feature, but no patch has been posted yet: "https://bugs.webkit.org/show_bug.cgi?id=38520":https://bugs.webkit.org/show_bug.cgi?id=38520
Feel free to post a patch if you want to help.
-
You could look at how -webkit-user-select is implemented. Disabling selection is probably using the same path.
-
There is a thread on this subject on the mailing list: "https://lists.webkit.org/pipermail/webkit-qt/2010-October/000896.html":https://lists.webkit.org/pipermail/webkit-qt/2010-October/000896.html
-
I bug is already filed here at bugzilla, for this
https://bugs.webkit.org/show_bug.cgi?id=38520 -
Wow here is way you can do it
@
QApplication a(argc, argv);
QWebView *view = new QWebView;
view->load(QUrl("http://google.com"));
view->page()->settings()->setUserStyleSheetUrl(QUrl::fromLocalFile("mycss.css"));
view->show();
return a.exec();@your css file should be like this:
body {
-webkit-user-select: none;
} -
your submitted code is very helpful for disable the selection on text and image.
but your code is not helpful in case while user drag the image with press button. -
@kmsharad83 This is what I do in jQuery. You can adapt it to your needs:
$(document).ready(function(){ // Prevent anchor links and buttons and .nodrag items from being dragged $('A,BUTTON,.nodrag,IMG') .css('-moz-user-select','none') .css('-webkit-user-select','none') .bind('selectstart', function(e) { e.preventDefault(); return false; }) .bind('draggesture', function(e) { e.preventDefault(); return false; }) .bind('draggable', function(e) { e.preventDefault(); return false; }) .bind('dragstart', function(e) { e.preventDefault(); return false; }); });