开发者

In Gtk, how do I make a CellRendererToggle in a TreeViewColumn with multiple CellRenderers only get toggled when the checkbox itself is clicked?

I have a TreeModel representing a tree of Tags. Each Tag has these properties, among others:

string Name
bool Active
Tag Parent
TagList Children //basically just a List<Tag>

The TreeView has a single column, with two CellRenderers: a CellRendererToggle for Active, and 开发者_JAVA技巧a CellRendererText for Name. I want them in the same column, because multiple columns gets messy as you get farther down the descendants in the TreeView.

My problem is that when I click anywhere in the column, the CellRendererToggle is toggled. This is problematic, because I want to do things like dragging the tags, and renaming them inline. Is there any way to make the CellRendererToggle only get toggled when I click on the checkbox itself, without moving it to a separate column?


You need to set the CellRenderer's Mode to Activatable:

renderer.Mode = CellRendererMode.Activatable;

If a renderer is not activatable, but another renderer in the column is, Gtk passes on the click to that renderer. Setting your non-toggle renderers to be activatable, too, keeps them from passing on the click.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜