Re: Correct signal handler to overload in a treeview to STOP the selection from changing



Bob Caryl wrote:

Huston, Bob wrote:

I have a treeview derived class, in which when a branch in the tree is displayed I display a notebook derived class showing many GUI controls for information gathering. When the user selects a different branch in the tree, I save off the currently displayed notebook information
and display a new notebook for the new branch that is selected.
I accomplish this by overloading the on_cursor_changed signal handler in the tree view class. The issue I am having is that when I am switching notebooks being displayed I validate any and all information on the current notebook, if the information is valid, I want to warn the user via and keep the tree from switching views. I am not switching the notebooks when this occurs, however the tree is still switching which branch is selected. My code basically is this: void CMyTreeView::on_cursor_changed()
{
    // save/validate the current notebook:
    if ( !SaveCurrentNotebook())
        return;
// put up the new notebook
    .....
    return Gtk::TreeView::on_cursor_changed();
}
I need to know how to either return from this handler so that the selection doesn't change, or a different handler to overload to do my processing prior to the selection change occurs. I thought that by not allowing the parent tree view class's version of on_cursor_changed to be called that this would happen. --Bob
------------------------------------------------------------------------

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

Hey Bob,

I could not find a signal directly relating to the Gtk::TreeView to which you could connect in order to prevent the TreeView from changing rows in response to a mouse click (and remember, a row can also be changed with the arrow keys on the keyboard). However, you might consider connecting to "Gtk::Main::signal_key_snooper" and looking for a "GDK_BUTTON_PRESS" event (see GdkEventButton http://www.gtk.org/api/2.6/gdk/gdk-Event-Structures.html#GdkEventButton <http://www.gtk.org/api/2.6/gdk/gdk-Event-Structures.html#GdkEventButton>). You can compare the GdkWindow pointer to the GdkWindow corresponding to your Gtk::TreeView in your connected callback slot to determine whether or not to allow the cursor to change depending on the validation of your controls in your notebook page.

Connection code looks like this:

Gtk::Main::signal_key_snooper().connect(sigc::mem_fun(*this,&<your class name here>::<your callback slot name here>));

I don't know if this will actually work, but I do know that you can choose to go ahead a propagate the event or not in your callback. If you do propagate it, you must be sure to prevent catching that event a second (and third and fourth and so forth) time.

Hope this might help.

Bob Caryl

_______________________________________________
gtkmm-list mailing list
gtkmm-list gnome org
http://mail.gnome.org/mailman/listinfo/gtkmm-list
Hey Bob,

Well, I wish now I had taken the time to test my theory. It doesn't work. Apparently this signal is triggered *only* by keyboard input (as its name implies). Sorry.

Bob Caryl
begin:vcard
fn:Robert Caryl
n:Caryl;Robert
org:Fiscal Systems, Inc.
adr:;;102 Commerce Circle;Madison;AL;35758;USA
email;internet:bob fis-cal com
title:Senior Software Design Engineer
tel;work:356-772-8920 X108
x-mozilla-html:TRUE
url:http://www.fis-cal.com
version:2.1
end:vcard



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]