6

OK, from the "I never expected THIS to be the hard part" department: how do I set the text of a NSTextField in Xamarin Mac?

  NSTextView view = new NSTextView(new RectangleF(0, 500, 200, 40));
  view.StringValue = "Foo";

does not compile (no method "StringValue"). Nor does SetStringValue("Foo"). Nor does there appear to be any SetText method. There's an InsertText method, but it doesn't take a C# string; it wants an NSObject (which makes me think it's not really intended for direct use).

Note that if I use NSTextField instead of NSTextView, I can assign to StringValue just fine. But with NSTextField, the same code fails.

I'm experienced in ObjC programming on iOS, but pretty much a noob to both Mac Cocoa and Xamarin Mac. So I'm sure I'm missing some obvious answer, but my googling hasn't found an answer (and the Xamarin forums are down today). Any help will be greatly appreciated.

Joe Strout
  • 2,634
  • 2
  • 28
  • 39

1 Answers1

5

Have you tried the Value property?

http://forums.xamarin.com/discussion/14870/how-to-add-text-to-a-text-view-nstextview-in-a-nsscrollview-from-ib

Jason
  • 86,222
  • 15
  • 131
  • 146
  • Nope, didn't see that one! Thank you! – Joe Strout Apr 19 '14 at 16:08
  • ...although it appears that Value doesn't work with an NSTextField. It's weird that you don't assign text to these two (closely related?) controls in the same way. But whatever works, I guess! – Joe Strout Apr 19 '14 at 16:09