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

Caleb Land redhatdude at gmail.com
Tue Jun 28 02:41:40 EDT 2005


I'm using:

Mono 1.1.8.1 <http://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.Int32position)


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)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://galactus.ximian.com/pipermail/gtk-sharp-list/attachments/20050628/1711a3cf/attachment.html


More information about the Gtk-sharp-list mailing list