Re: [gtkmm] right-click in declarated Gtk::TreeView ("solved")



Hi,

Those who've red my thread about right-clicking in a declarated treeview
are probably interested in my findings.

Gergo provided me with a solution which works with single and
multi-selection and can be found in:

"GNOEM CVS, module guikachu, tag guikachu-gnome-2-branch, file 
src/form-win-widgettree.cc"

This works smoothless, but if you only use single-selection there is a
shorter way to accomplish the same:

----------------< snippet  gtkmm-2.4 >--------------------------

treeview.signal_button_press_event().connect_notify( 
sigc::mem_fun(*this, &DetailWindow::treeview_click) );

void DetailWindow::treeview_click(GdkEventButton* event)
{
  if ( event->button == 3 ) {
    treeview.get_path_at_pos( (int)event->x,
                              (int)event->y,
                              path,
                              temp_column,
                              x,
                              y );
    treeview.set_cursor(path);

    /*the clicked path is selected, so now it's safe
     *to add your custom code
     */
    
  }

}
------------------------------------------------------------------------

Maybe it'll help some people one day. I personally hate it when i find a
description of my problem in an mailingarchive and the answer is
unfindable :^)

grtz,

Bart





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