Re: [gtkmm] TreeView selection question



On Wed, 29 Sep 2004 10:57:45 -0400, Carl Nygard <cjnygard fast net> wrote:

On Wed, 2004-09-29 at 03:57, Marco Scholten wrote:
----- Original Message -----
From: "Carl Nygard" <cjnygard fast net>
To: <gtkmm-list gnome org>
Sent: Wednesday, September 29, 2004 5:05 AM
Subject: [gtkmm] TreeView selection question


>
> I have a treeview with two columns, first is a simple check button,
> second column is a label.
>
> I'd like to be able to toggle the check buttons in various rows without
> actually selecting the row.
>
> But of course, I don't know how to accomplish that.  Clues???
>
> Regards,
> Carl
>
> _______________________________________________
> gtkmm-list mailing list
> gtkmm-list gnome org
> http://mail.gnome.org/mailman/listinfo/gtkmm-list
>

Maybe this will help, taken form
http://www.gtkmm.org/gtkmm2/docs/tutorial/html/ch08s04.html

Preventing row selection

Maybe the user should not be able to select every item in your list or tree. For instance, in the gtk-demo, you can select a demo to see the source code,
but it doesn't make any sense to select a demo category.

To control which rows can be selected, use the set_select_function() method,
providing a SigC::Slot callback. For instance:

m_refTreeSelection->set_select_function( SigC::slot(*this,
&DemoWindow::select_function) );

and then

bool DemoWindow::select_function(const Glib::RefPtr<Gtk::TreeModel>& model,
                                 const Gtk::TreeModel::Path& path, bool)
{
  const Gtk::TreeModel::iterator iter = model->get_iter(path);
return iter->children().empty(); // only allow leaf nodes to be selected
}

That's fine, but how do I decide to ignore it?  The problem is that I
only want to ignore the selection if the checkbox was toggled, but I
don't know that information.  Unless the Path tells me which cell was
chosen?

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

Experiment a little with Gtk::CellRendererToggle::signal_toggled () to detect if the checkbox was toggled or Gtk::TreeViewColumn::signal_clicked() to detect wich column was clicked, set some variable like last_clicked_column, and return (last_clicked_column != 0) in DemoWindow::select_function() I don't know if this will work because i don't know if these signals get fired before or after the select function.

Regards,
 Marco



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