[Gtk-sharp-list] subclass a gtk.spinbutton
Michael Hutchinson
m.j.hutchinson at gmail.com
Tue Apr 18 19:33:30 EDT 2006
On 4/19/06, David Cantin <david_cantin at videotron.ca> wrote:
> Hi, I'm trying to sublcass a spinbutton to get some extra behaviour but
> I don't know to do it and i do not find any relevant example on the web.
>
> what I have for now is the code below but I get errors related to null
> pointer instance when I try to use my MySpinButton class.
<snip>
You shuldn't need to use IntPtrs. In GTK# these are used to point to
the unmanaged (C) GTK objects that the GTK# classes wrap. AFAIK the
constructors taking pointers are intended to wrap existing unmanaged
objects - in the documentation it says they are for *internal* use.
You are initialising the base class with a null pointer, as you have
not assigned any value to it, and hence it is wrapping nothing. Even
if you did assign a value to it, unless it was the address of a Gtk+
SpinButton I suspect things would behave unpredicably strangely.
Use one of the other constructors, as they will create the unmanaged
SpinButton for you. If you do this, subclassing works pretty much as
you would expect it to.
Michael
More information about the Gtk-sharp-list
mailing list