在 Gtk 中,如何在具有多个 CellRenderer 的 TreeViewColumn 中制作 CellRendererToggle 仅在单击复选框本身时才切换?
我有一个代表 Tag
树的 TreeModel。每个 Tag
都有这些 属性等:
string Name
bool Active
Tag Parent
TagList Children //basically just a List<Tag>
TreeView
有一个列,有两个 CellRenderer
: CellRendererToggle
表示 Active
,CellRendererText
表示 Name
。我想 它们在同一列中,因为多列会变得混乱 进一步了解 TreeView
中的后代。
我的问题是,当我单击列中的任意位置时, CellRendererToggle
已切换。这是有问题的,因为我想 执行诸如拖动标签并内联重命名之类的操作。有没有 有什么办法可以让 CellRendererToggle
仅在我点击时切换 在复选框本身上,而不将其移动到单独的列?
I have a TreeModel
representing a tree of Tag
s. 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 CellRenderer
s: aCellRendererToggle
for Active
, and 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, theCellRendererToggle
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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您需要将
CellRenderer
的Mode
设置为Activatable
:如果一个渲染器不可激活,但列中的另一个渲染器可以激活,则Gtk会通过单击该渲染器。将非切换渲染器设置为可激活也可以防止它们传递点击。
You need to set the
CellRenderer
'sMode
toActivatable
: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.