Yeah, after some more playing around, I was able to get it to work
like that. I assumed that the event was already being hooked up
behind the scenes, like the speech synthesizer example, but maybe for
ones that are defined in the nib file, thats the way it needs to be
done.
On Aug 26, 2008, at 11:15 PM, osx wrote:
forgot to mention that you'll still have to hook up the text field's
delegate to your controller using interface builder.
osx writes:
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";
}
}