Re: Treeview with editable checkboxes besides items?

Milosz Derezynski wrote:
That's not really how this works. Instead:

- You associate the renderer with an e.g. boolean column:
column->add_property (*cell, "active",
- You connect to the toggled() signal: cell->signal_toggled().connect
(sigc::mem_fun (*this, &YourClass::callback_toggled))
- In the handler you do something like:

callback_toggled (Glib::ustring const& string_path)
  TreeIter iter = your_model->get_iter (string_path);
  (*iter)[your_column_instance.bool_col] = !bool

This approach works fine. Thanks!

There is one minor issue now. Clicking the name (not the checkbox!) also toggles the checkbox. This is annoying if the user only wants to change the selection. Is there a way to prevent this? Changing the name works more intuitive: the first click changes the selection and editing starts with another click.

Because, really, a cell renderer is in the first place only there to
represent data.

Having a "togglebutton cellrenderer" might be confusing at first because it
seems to imply that now the view can handle model data by itself, but in
fact for TreeView the model is read only.

Even in an "editing-done" callback for a CellRendererText, you are only
being supplied with the new text, and are still responsible for effectively
updating the model yourself (in the most simple case, analogous to the above
code, set the new text into the model column the relevant cell is

I still don't understand why I need to update the model myself with a CellRendererToggle. Because for a CellRendererText, all I need is:

renderer->property_editable() = true;

and editing works automatically. I would think that "property_activatable" does exactly the same thing for CellRendererToggle. But it doesn't seem to do that (or even anything at all). Because if I update the model myself from the signal handler, the value of "property_activatable" does not matter anymore. So what is it supposed to do?

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