gpt4 book ai didi

rust - GtkEventBox 将信号连接到 Glade 中的 GAction

转载 作者:行者123 更新时间:2023-11-29 08:08:29 25 4
gpt4 key购买 nike

我正在尝试通过 Glade 将 GtkEventBox 的 enter-notify-event 连接到附加的 GAction。使用 GtkInspector 检查正在运行的应用程序显示没有任何连接到 enter-notify-event 信号。

我正在关注 this blog post其中指出:

You could also set the properties via the .ui file. When you replace the event handlers of clicks with actions you can really streamline your code base.

所以我认为这在某种程度上应该是可能的。它只提到了 GtkButton 的点击处理程序,但我不明白为什么它应该与其他信号不同。

林间空地:

glade

检查员:

inspector

<object class="GtkEventBox" id="service_row">
<property name="visible">True</property>
<property name="can_focus">False</property>
<signal name="enter-notify-event" handler="test.show-arrow" swapped="no"/>

( complete UI file )

let actions = SimpleActionGroup::new();
let show_arrow = SimpleAction::new("show-arrow", None);
actions.add_action(&show_arrow);
show_arrow.connect_activate(move |_action, _data| {
println!("enter row2");
});
row.insert_action_group("test", &actions);
// row.connect_enter_notify_event(move |_widget, _crossing| {
// actions.activate_action("show-arrow", None);
// Inhibit(false)
// });

通过推荐行中的代码手动激活 GAction 效果很好。当查看 EventBox 时,该操作也会显示在检查器中。

非常感谢任何帮助:)

最佳答案

我认为你做不到。 GtkActionable仅针对具有明确用户激活操作的小部件实现,例如按钮或菜单项。特别是 GtkEventBox 没有实现它。

即使是这样,这个接口(interface)也只会管理每个类的一个事件,activate 操作,而不是您感兴趣的 enter-notify-event

因此,恐怕您将不得不继续手动连接您的事件。

关于rust - GtkEventBox 将信号连接到 Glade 中的 GAction,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54125491/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com