[Gtk-sharp-list] Override Gtk.Entry's OnTextInserted

Dan Winship danw at novell.com
Thu Jun 30 13:12:10 EDT 2005


This is now fixed in svn (revision 46773). There was a problem with how
pass-by-ref args in signals were being handled. Unfortunately, there
isn't really any way to work around it in 1.9.5.

-- Dan

On Tue, 2005-06-28 at 02:41 -0400, Caleb Land wrote:
> I'm using:
> 
> Mono 1.1.8.1,
> gtk-sharp-1.9.5,
> Ubuntu Linux 5.04
> 
> I'd like to override the default handler OnTextInserted to implement
> an inputmask property.  The idea was to modify the parameters before
> they were passed into the base class's handler so I could determine
> whether characters were added or not.  When I try to call the base
> class's implementation I get this error:
> 
> Unhandled Exception: System.NullReferenceException: Object reference
> not set to an instance of an object
> in <0x00000> <unknown method>
> in (wrapper managed-to-native)
> GLib.Object:g_signal_chain_from_overridden (intptr,GLib.Value&)
> in <0x00257> Gtk.Entry:OnTextInserted (System.String text,
> System.Int32 position)
> 
> 
> Is it possible to use the base class's implementation?  If not, does
> anybody have any pointers on how to accomplish what I want to do?
> 
> 
> Here is a bit of code that I'm using:
> 
> // created on 6/28/2005 at 2:09 AM
> using System;
> using Gtk;
> using GtkSharp;
> 
> namespace MyWindow
> {
>     public class MyEntry : Entry {
>         public MyEntry () : base () {
>         }
> 
>         public MyEntry (string text) : base (text) {
>         }
> 
>         protected override void OnTextInserted (string text, ref int
> position) {
>             base.OnTextInserted (text, ref position);
>         }
>     }
>     public class CreatedWindow : Window
>     {
>         public static void Main (string[] args) {
>             Application.Init ();
>             CreatedWindow c = new CreatedWindow ();
>             Application.Run ();
>         }
>         public CreatedWindow () : base ("MyWindow")
>         {
>             MyEntry e = new MyEntry ();
>             this.Add (e);
>             this.DeleteEvent += new DeleteEventHandler
> (DeletedCallback);
>             this.ShowAll();
>         }
> 
>         static void DeletedCallback (object o, DeleteEventArgs args) {
>             Application.Quit();
>         }
>     }
> }
> 
> -- 
> Caleb Land
> (RedHatDude at gmail.com) 
> _______________________________________________
> Gtk-sharp-list maillist  -  Gtk-sharp-list at lists.ximian.com
> http://lists.ximian.com/mailman/listinfo/gtk-sharp-list



More information about the Gtk-sharp-list mailing list