[perl-Glib-Object-Introspection] Add some docs about overriding virtual functions



commit 2046d7494833aeff538fdbe578ecba0c4788eec9
Author: Torsten Schönfeld <kaffeetisch gmx de>
Date:   Sun May 20 17:25:23 2018 +0200

    Add some docs about overriding virtual functions

 lib/Glib/Object/Introspection.pm |   15 +++++++++++++++
 1 files changed, 15 insertions(+), 0 deletions(-)
---
diff --git a/lib/Glib/Object/Introspection.pm b/lib/Glib/Object/Introspection.pm
index d8f1cae..c22dca8 100644
--- a/lib/Glib/Object/Introspection.pm
+++ b/lib/Glib/Object/Introspection.pm
@@ -527,6 +527,21 @@ example:
   my $button = Gtk3::Button->new;
   Gtk3::WidgetClass::find_style_property ($button, 'image-spacing')
 
+=head2 Overriding virtual functions
+
+When subclassing a gtk+ class or when implementing a gtk+ interface with
+L<Glib::Object::Subclass>, you can override any virtual functions that the
+class has by simply defining sub routines with names obtained by capitalizing
+the original names of the virtual functions.  So, for example, if you implement
+a custom subclass of C<Gtk3::CellRenderer> and want to override its virtual
+function C<render>, you provide a sub routine with the name C<RENDER> in your
+package.
+
+  sub RENDER {
+    my ($cell, $cr, $widget, $background_area, $cell_area, $flags) = @_;
+    # do something
+  }
+
 =head1 DESCRIPTION FOR LIBRARY BINDING AUTHORS
 
 =head2 C<< Glib::Object::Introspection->setup >>


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]