Re: Applying a TextTag on newly-written Text
- From: Armin Burgmeier <armin arbur net>
- To: gtkmm-list gnome org
- Subject: Re: Applying a TextTag on newly-written Text
- Date: Fri, 03 Jun 2005 23:49:00 +0200
Hi once again,
well, thats quite exactly what I am doing, and it does not show up the
applied tag immediately. I wrote a small application that shows up just
a text view that colors incoming text, to ensure that noting else in my
application causes the problem, but the behavior did not change.
I attached this small piece of code to this mail, maybe you can find out
what's wrong, maybe it works for you, maybe you cannot, but I thank you
for you effort anyways.
Armin
#include <gtkmm/textview.h>
#include <gtkmm/scrolledwindow.h>
#include <gtkmm/window.h>
#include <gtkmm/main.h>
class MyView : public Gtk::TextView
{
public:
MyView()
{
Glib::RefPtr<Gtk::TextTag> tag =
get_buffer()->create_tag("orange");
tag->property_background() = "orange";
add_events(Gdk::KEY_PRESS_MASK);
}
protected:
virtual bool on_key_press_event(GdkEventKey* event)
{
Gtk::TextView::on_key_press_event(event);
get_buffer()->remove_all_tags(get_buffer()->begin(), get_buffer()->end() );
get_buffer()->apply_tag_by_name("orange", get_buffer()->begin(), get_buffer()->end() );
return true;
}
};
int main(int argc, char* argv[])
{
Gtk::Main kit(argc, argv);
MyView view;
Gtk::ScrolledWindow wnd;
Gtk::Window mainw;
wnd.add(view);
mainw.add(wnd);
mainw.show_all();
Gtk::Main::run(mainw);
return 0;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]