[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-devel
Subject:    Re: Text selection in KHTML
From:       David Faure <faure () kde ! org>
Date:       2006-11-28 21:09:37
Message-ID: 200611282209.38132.faure () kde ! org
[Download RAW message or body]

On Tue Nov 28 2006, Sergejs Melderis wrote:
> Hi,
> I have a question about text selection in KHTML.  I am using KHTMLPart in my
> small application. By default double clicking on a peace of text that
> contains only one word selects the text. But I want to select a text that
> contains multiple words by dragging a mouse with pressed left button, the
> same way it works in Konqueror. I was able to get it to work by calculating
> "number of characters" in a pixel in a DOM::Node by simply dividing DOM::
> Node.nodeValue().length() / DOM::Node.getRect().width(); Then I just
> calculated a DOM::Range in MouseMoveEvent and call
> KHTMLPart::setSelection(DOM::Range). It works very well, but only when
> DOM::Node does not span multiple lines. When it does the proportion
> chars/pixel is wrong. I don't know x coordinate where the text ends.  I
> tried to find how it is done in Konqueror, but could not find it. Can some
> one point me how to do it or where to find similar code since it works in
> Konqueror out of the box.

What's for sure is that Konqueror itself doesn't do any of this, it's all done by KHTML.
But I fail to see why khtml would act differently in terms of text selection, between
being used in konqueror and being used in your app... Unless some mouse events get
filtered out, it should really just work the same. Are you sure it's the same version of
KHTML that you're using and that konq is using?

-- 
David Faure, faure@kde.org, sponsored by Trolltech to work on KDE,
Konqueror (http://www.konqueror.org), and KOffice (http://www.koffice.org).
 
>> Visit http://mail.kde.org/mailman/listinfo/kde-devel#unsub to unsubscribe <<
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic