views:

76

answers:

1
class HelloApp
        attr_accessor :label, :text_field, :button
        def clickedButton(sender)
            # implementation
            your_name = self.text_field.stringValue
            self.label.stringValue = "Hello,  #{your_name}"
        end
end

The above code is in HelloApp.rb The problem is when I type something into the textbox, and click the button, the label just says "Hello, " and not "Hello, namegoeshere" I am using MacRuby .4 by the way.

A: 

Your code works for me in MacRuby .5

Does this log the user input to the console?

your_name = self.text_field.stringValue
puts "Your name is #{your_name}" 

If not, you may not have the text_field hooked up to the NSTextField in Interface Builder.

Craig Williams