ashbb / green_shoes

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

element remove method failed in click event. #63

Closed athom closed 12 years ago

athom commented 12 years ago

the other events like hover, release is all ok, but not click.

require 'green_shoes'

Shoes.app do
   img1 = image 'ruby2.png'
   img1.click do 
     img1.remove
   end
end
C:\Users\fanca\Documents\My Dropbox\todo>ruby img_hover_test.rb
C:/Ruby192/lib/ruby/gems/1.9.1/gems/green_shoes-1.1.358/lib/shoes/helper_methods
.rb:288:in `block in set_cursor_type': undefined method `cursor=' for nil:NilCla
ss
         from C:/Ruby192/lib/ruby/gems/1.9.1/gems/green_shoes-1.1.358/lib/shoes/
helper_methods.rb:285:in `each'
         from C:/Ruby192/lib/ruby/gems/1.9.1/gems/green_shoes-1.1.358/lib/shoes/
helper_methods.rb:285:in `set_cursor_type'
         from C:/Ruby192/lib/ruby/gems/1.9.1/gems/green_shoes-1.1.358/lib/shoes/
main.rb:100:in `block in app'
         from C:/Ruby192/lib/ruby/gems/1.9.1/gems/green_shoes-1.1.358/lib/shoes/
main.rb:109:in `call'
         from C:/Ruby192/lib/ruby/gems/1.9.1/gems/green_shoes-1.1.358/lib/shoes/
main.rb:109:in `main'
         from C:/Ruby192/lib/ruby/gems/1.9.1/gems/green_shoes-1.1.358/lib/shoes/
main.rb:109:in `app'
         from img_hover_test.rb:3:in `<main>'
C:/Ruby192/lib/ruby/gems/1.9.1/gems/green_shoes-1.1.358/lib/shoes/ruby.rb:106:in
 `exit': wrong number of arguments (1 for 0) (ArgumentError)
        from C:/Ruby192/lib/ruby/gems/1.9.1/gems/glib2-1.0.3-x86-mingw32/lib/gli
b2.rb:32:in `exit_application'
        from C:/Ruby192/lib/ruby/gems/1.9.1/gems/green_shoes-1.1.358/lib/shoes/m
ain.rb:109:in `main'
        from C:/Ruby192/lib/ruby/gems/1.9.1/gems/green_shoes-1.1.358/lib/shoes/m
ain.rb:109:in `app'
        from img_hover_test.rb:3:in `<main>'

C:\Users\fanca\Documents\My Dropbox\todo>
ashbb commented 12 years ago

Yeah, in Green Shoes, don't use remove method, just use clear method, please.

athom commented 12 years ago

hi, ashbb after simply adding some code the 288 in helper_methods.rb and it works. maybe it could avoid other bugs however, I will follow your advice to use clear in stead of remove. thanks for your info.

original:

app.mccs.each do |e|
  next if e.is_a? Slot
  e.real.window.cursor = ARROW if e.real.window
  (e.real.window.cursor = HAND; return) if mouse_on? e
end

modified:

app.mccs.each do |e|
  next if e.is_a? Slot
  e.real.window.cursor = ARROW if e.real.window
  (e.real.window.cursor = HAND; return) if mouse_on? e and e.real.window
end
ashbb commented 12 years ago

Hi yeer,

Good code! Could you send me a pull request? I'll merge. I'd like to see your name in the commit list on GitHub. Thanks!