When you override a virtual signal, you only override its default handler, so you don't specify 'signal' in the new method: public class MyListBox : Gtk.ListBox { public override void set_focus_child (Widget? widget) { // override default handler here } } Not sure here, but I think that if you define a signal without a default handler, it is not possible to override it as it does not exist. There's also mechanism to stop signals from bubbling in GObject if that can help you: http://www.valadate.org:8000/#!api=gobject-2.0/GLib.Signa l However, I don't know how to fetch the signal id from Vala. Le jeudi 28 juillet 2016 à 18:22 +1000, Michael Gratton a écrit :
Hey all, I have a subclass of Gtk.ListBox and I'm trying to override Gtk.Container::gtk_container_set_focus_child on it to prevent its default behaviour of automatically scrolling to the new focus child. The docs for that method say this:This function emits the GtkContainer::set_focus_child signal of container. Implementations of GtkContainer can override the default behaviour by overriding the class closure of this signal.How exactly do I do that? I tried overriding the method using:public override void set_focus_child(Gtk.Widget? child) { ... }But even if I do not chain up using a call to "base.set_focus_child(child)", it seems Gtk.Container's method is still invoked. I also tried overriding the signal body using variously:public override signal void set_focus_child(Gtk.Widget? child) { ... } public new signal void set_focus_child(Gtk.Widget? child) { ... }But then valac complains that it "hides inherited signal" in the first case and "Only virtual signals can have a default signal handler body" for both. Any hints? Thanks! //Mike
-- Guillaume Poirier-Morency <guillaumepoiriermorency gmail com> Étudiant au baccalauréat en Informatique à l'Université de Montréal Développeur d'application web Mon blog: https://arteymix.github.io/ Mon projet de coopérative: https://pittoresque.github.io/ Clé PGP: B1AD6EA5
Attachment:
signature.asc
Description: This is a digitally signed message part