I am using a non-editable, non-senstiive GtkText
inside a ListBoxRow
and set the GtkText
editable and sensitive on row activation. My goal is to display the GtkText
the same way as if it was a GtkLabel
, but also allow edition only on row activation, and disallow it on mouse leave event.
On mouse leave event on the GtkText (captured with a GtkEventControllerMotion) I reset the GtkText to non-sensitive and non-editable. I understand this breaks the flow of event propagation, but I don’t know how to work around that. On mouse leave event, i get such a warning:
GtkText - did not receive a focus-out event.
If you handle this event, you must return
GDK_EVENT_PROPAGATE so the default handler
gets the event as well
The relevant “on mouse leave” Vala code is as follow:
/* in row constructor */
label = new Text ();
label.editable = false;
label.sensitive = false;
var mouse_ev = new Gtk.EventControllerMotion ();
mouse_ev.leave.connect_after (() => { label.editable = label.sensitive = false; text_edited (label.text); });
// useless alternate code
// mouse_ev.leave.connect_after (() => { GLib.Idle.add (() => { label.editable = label.sensitive = false; return false; }); text_edited (label.text); });
label.add_controller (mouse_ev);
...
I’m stuck on how to get rid of the warning message. I’m probably doing this wrong, even if from the UX point of view, the code works as expected.