ashbb / green_shoes

Green Shoes is one of the colorful Shoes written in pure Ruby.
Other
204 stars 37 forks source link

change handler does not work for EditBox #50

Closed translunar closed 12 years ago

translunar commented 12 years ago
Shoes.app(:title => "Test") do
  edit_box :text => "Test text" do
    change do
      puts "Hi!"
    end
  end
end

This gives the following error:

(irb):4:in `block (2 levels) in irb_binding': undefined method `change' for #<Shoes::App:0x9bb1fe4>
 from /usr/local/lib/ruby/gems/1.9.1/gems/green_shoes-1.0.282/lib/shoes/app.rb:285:in `block in edit_box'
 from /usr/local/lib/ruby/gems/1.9.1/gems/green_shoes-1.0.282/lib/shoes/main.rb:105:in `call'
 from /usr/local/lib/ruby/gems/1.9.1/gems/green_shoes-1.0.282/lib/shoes/main.rb:105:in `main'
 from /usr/local/lib/ruby/gems/1.9.1/gems/green_shoes-1.0.282/lib/shoes/main.rb:105:in `app'
ashbb commented 12 years ago

Hi John,

Green Shoes doesn't change self within a block of edit_line. So, use a change event with one of the following three styles.

require 'green_shoes'
Shoes.app do
  edit_line{puts 'hi'}
end
require 'green_shoes'
Shoes.app do
  edit_line change: proc{puts 'hi'}
end
require 'green_shoes'
Shoes.app do
  el = edit_line
  el.change{puts 'hi'}
end

ashbb