[MacRuby-devel] Cocoa Bindings not writing?

Alan Skipp al_skipp at fastmail.fm
Wed Feb 9 01:48:01 PST 2011


I think if you define an accessor for 'name' with attr_accessor as you have done with someTextField, then this should work. 
You can then remove the accessor methods you have created for the 'name' instance var. 

On 9 Feb 2011, at 08:51, Robert Payne <robertpayne at me.com> wrote:

> Hi,
> 
> I'm not sure if this is technically supposed to work in MacRuby but it definitely works in objective-c.
> 
> class MyClass < NSWindowController
> 
> 	attr_accessor :someTextField
> 
> 	def name()
> 		return @name
> 	end
> 	
> 	def setName(value)
> 		@name = value
> 	end
> 
> 	def windowDidLoad()
> 		@name = "Robert"
> 		self.someTextField.bind("value", toObject:self, withKeyPath:"name", options:nil)
> 	end
> 
> end
> 
> I also tried binding the text field's value directly via interface builder but it doesn't work there either. Interestingly if you set the "name" on the class inside MacRuby it'll update the text field but updating the text field via the GUI doesn't bring the new value back down into MacRuby.
> 
> Are bindings something that have to be done with Cocoa controllers?
> 
> Thanks,
> Robert Payne
> _______________________________________________
> MacRuby-devel mailing list
> MacRuby-devel at lists.macosforge.org
> http://lists.macosforge.org/mailman/listinfo.cgi/macruby-devel
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/macruby-devel/attachments/20110209/c7b70b85/attachment-0001.html>


More information about the MacRuby-devel mailing list