i have not tried the same method you're using, but this other way worked for me:
 [ObjectiveCMessage("controlTextDidChange:")]
 public void controlTextDidChange(NSNotification n)
 {
   this.OnTextChanged(n);
}

David Rivera writes:
Hello! I'm a new user of monobjc, and I must say, so far I love it! Brilliant job! I am having an issue though, and I'm not sure if I'm just doing something wrong or what. I am trying to add a handler for the CpontrolTextDidChange event on a NSTextField, but the event never seems to fire. The text field is in the nib file, not created programatically (that might be the issue), and I have a hooked up outlet for it in my controller class. I can change the text of the field programatically and manually, but neither way seems to fire off the event. Any hints as to what I may be doing wrong? Here is my controller class:
        [ObjectiveCClass]
        public class AppController : NSObject
        {
                [ObjectiveCField]
                public NSTextField outputText;
                
                public AppController()
                {
                }
                
                public AppController(IntPtr nativePointer) : base(nativePointer)
                {
                }
                
                [ObjectiveCMessage("awakeFromNib")]
                public void AwakeFromNib()
                {
                        outputText.StringValue = "Awoke from nib";
                        
                        outputText.ControlTextDidChange += this.OnTextChanged;
                }
                
                public void OnTextChanged(NSNotification n)
                {
AppKitFramework.NSRunAlertPanel("HelloCocoa", String.Format("Text Changed!"), "OK", null, null);
                }
                
                [ObjectiveCMessage("startClicked:")]
                public void StartClicked(Id sender)
                {
                        outputText.StringValue = "Button Clicked";
                }
}

Reply via email to