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

List:       kde-devel
Subject:    Text selection in KHTML
From:       "Sergejs Melderis" <sergey.melderis () gmail ! com>
Date:       2006-11-25 17:00:03
Message-ID: 3fb342ab0611250900q1143208cqbf8401d03d329d0b () mail ! gmail ! com
[Download RAW message or body]

[Attachment #2 (multipart/alternative)]


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.

-- 
Sergejs Melderis

[Attachment #5 (text/html)]

Hi, <br>I have a question about text selection in KHTML.&nbsp; 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 &quot;number of \
characters&quot; 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.&nbsp; \
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. <br clear="all"><br>-- <br>Sergejs Melderis



>> 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