Hello,

You have forgotten to export the method override with the
ObjectiveCMessage attribute. Without this attribute, the method is not
exposed in the Objective-C runtime.

                [ObjectiveCMessage("keyUp:")] // <-- Mandatory attribute
                public override void KeyUp (NSEvent theEvent)
                {
                        base.KeyUp (theEvent); // <-- Don't call base.
Use this.SendMessageSuper()
                        keyUpHandler();
                }

Note that you cannot make calls with the base specifier, as you are
using wrappers. Please use this.SendMessageSuper() as stated in the
documentation (http://www.monobjc.net/index.php?page=messaging).

Regards, Laurent Etiemble.

2010/1/31 Yvan Janssens <y...@yvansoftware.be>:
> Hi,
>
> In the following source file, I get the following unexpected behavior:
>
>
> using System;
> using Monobjc;
> using Monobjc.Cocoa;
> namespace YvanSoftware.TwitMenu
> {
>
>        [ObjectiveCClass("LengthField")]
>        public class NSTextField_Length : NSTextField
>        {
>                const int maxLength = 160;
>
>                [ObjectiveCField("lblNumOfChars")]
>                public NSTextField lblNumOfChars;
>
>                public NSTextField_Length () : base()
>                {
>                }
>
>                public NSTextField_Length (IntPtr i)
>                        :base(i)
>                {
>                }
>
>
>                public override void KeyUp (NSEvent theEvent)
>                {
>                        base.KeyUp (theEvent);
>                        keyUpHandler();
>                }
>
>
>
>                void keyUpHandler() {
>
>                        Console.WriteLine("*** keyUp ***"); // Never shows 
> up...
>                        if (this.StringValue.Length >= maxLength) {
>                                this.StringValue = 
> this.StringValue.SubstringToIndex(maxLength);
>                        }
>                        lblNumOfChars.StringValue = "Chars: " +
> this.StringValue.Length.ToString() + "/" + maxLength.ToString();
>                }
>        }
> }
>
> I commented where the "error" takes place: the line ***keyUp*** never
> shows up, but if I put it in the constructors such a statement, it
> gets properly executed.
>
> What do I need to do?
>
> Thanks,
>
> Yvan
>

Reply via email to