Re: Applying a TextTag on newly-written Text
- From: "Krause" <andrew openldev org>
- To: <gtkmm-list gnome org>
- Subject: Re: Applying a TextTag on newly-written Text
- Date: Fri, 3 Jun 2005 09:05:14 -0700
>Hi Andrew,
>
>I tried it out, but this seems not to work for me, either. Could you
>give me a piece of code showing how you apply the tag in the event handler?
>
>Armin
bool ClassName::on_keystroke(GdkEventKey *key)
{
if (key->type == GDK_KEY_PRESS)
{
Glib::RefPtr<Gtk::TextBuffer> buffer = textview->get_buffer();
// You can use whatever method you want to get the begin
// and end text iterators
Gtk::TextIter begin = buffer->get_insert()->get_iter();
Gtk::TextIter end = begin;
end++;
// Apply the tag to the TextBuffer. 'tag' is whatever you
// want the TextTag to be
buffer->apply_tag(tag, begin, end);
// You really don't need this, but I do it for good measure.
textview->set_buffer(buffer);
}
}
I hope this helps. You will obviously have to edit the code to
fit your needs, but this should get you on track.
---
Andrew Krause
andrew openldev org
www.openldev.org
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]