Hi again,

Sorry to bother you guys again. I've been at this for a few days now and I really can't figure it out. What I'm trying to do is have a constant string or label in a text view buffer. Something like what gnome-terminal has with the username@host. What I've tried to do so far is connect to the textview signal_event and look for the backspace or delete key. That worked kind of, but, the user can still add text then delete the constant text. Here is the code for that:

|//in constructor
txt_view_i_.signal_event().connect(sigc::mem_fun(*this,  
&MainWindow::inputEvent));

//function
bool  MainWindow::inputEvent(GdkEvent*  event)
{
    if((event->key.keyval==  GDK_KEY_BackSpace||  event->key.keyval==  GDK_KEY_Delete)  
&&  buffer_input_->get_char_count()  <  3)
        return  true;

    return  false;
}|

I also tried adding a label to text view, but the same problem araised again, the user can delete the label. Here is the code for that:

|Gtk::TextBuffer::iterator  it=  buffer_input_->get_iter_at_line(1);
Glib::RefPtr<Gtk::TextChildAnchor>  refAnchor=  
buffer_input_->create_child_anchor(it);
Gtk::Label*  lbl=  Gtk::manage(new  Gtk::Label(">"));
txt_view_i_.add_child_at_anchor(*lbl,  refAnchor);

|||

||Any suggestions to what I can do?

Thank you all very much

Tim O.

||

_______________________________________________
gtkmm-list mailing list
gtkmm-list@gnome.org
https://mail.gnome.org/mailman/listinfo/gtkmm-list

Reply via email to