Tuesday 20 December 2005 23:32, David Saxton wrote:
Tuesday 20 December 2005 10:11, Dominik Haumann wrote:
The Kate Part implements *
There is also a texthintinterface: texthintinterface.h in which you can
find something like enableTextHints.
The KateView class in kdelibs/kate/part/kateview.h class is derived
from the TextHintInterface.
So you can cast a Kate::View into a KTextEditor::TextHintInterface and
call whatever is defined in this interface file.
Hope this helps, greetings,
Dominik
Yup, seems to be working :) - not too sure how I missed the
TextHintInterface interface.
Still though, it won't actually display any tool tips - despite what the
function description claims (unless I'm missing something again).
Instead, all it does is prints debug info:
emit m_view->needTextHint(c.line(), c.col(), tmp);
if (!tmp.isEmpty()) kdDebug(13030)<<"Hint text: "<<tmp<<endl;
}
Which means that I have to implement the tooltip myself. This is ok (I
can at least intercept events to hide the tooltip, etc) but I don't have
access to useful internal data such as the line positions (so that the
tooltip can be displayed just below the current line), for example.
The TextHintInterface works like this iirc:
1. You enable the hints with enableTextHints, you have done this already I
guess.
2. You connect the signal needTextHint to a slot, example:
connect( (KTextEditor::TextHintInterface*) my_view, // better: dynamic_cast
SIGNAL( needTextHint(int, int, QString&),
this, SLT( passTextHint(int, int, QString&) );
Note: You actually *never* call the signal yourself.
3. You implement passTextHint(int l, int c, QString& fill_me).
This slot is called whenever the mouse position hovers over a certain text
position without moving. The Kate Part registers this and then asks for a
string *from you* (by emitting the signal needTextHint!). You have the line
and column, so get the word at the position, do some stuff and pass the
return value back by using the reference fill_me.
I should add that I didn't test this, but I can't think of another ways how
it is supposed to work.
Greetings :)
Dominik
KWrite-Devel mailing list
KWrite-Devel (AT) kde (DOT) org