I am trying to connect the enter-notify-event
of an GtkEventBox to an attached GAction via Glade. Checking the running application with GtkInspector shows nothing connected to the enter-notify-event
signal.
I'm following this blog post which states:
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.
So I think this should somehow be possible. It only mentions a click handler of a GtkButton, but I don't see why it should be different with other signals.
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"/>
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)
// });
Manually activating the GAction via code like in the commended out lines works just fine. And the action also shows up in the Inspector when looking at the EventBox.
Any help is greatly appreciated :)
I don't think you can do that. GtkActionable
is only implemented for widgets that have a clear user-activate action, such as buttons or menu items. In particular GtkEventBox
does not implement it.
And even if it did, this interface will only manage one event per class, the activate action, not the enter-notify-event
you are interested in.
So, I'm afraid that you'll have to keep manually connecting your event.