shoes3 icon indicating copy to clipboard operation
shoes3 copied to clipboard

start, finish, hover, leave events are not referring to the correct self for Shoes App, Window and Dialog

Open IanTrudel opened this issue 10 years ago • 4 comments

Shoes App, Window and Dialog will not receive the proper self reference on start, finish, hover and leave events. They will instead receive Shoes, of class Shoes, that _does not respond to instance_methods_ and such. The stack in the code below is the only one behaving properly.

Shoes.app(:title => "Shoes Events", :width => 450, :height => 250) {
   start { |n| para "Shoes: #{n}\n" }
   hover { |n| para "Shoes (hover): #{n}\n" }
   leave { |n| para "Shoes (leave): #{n}\n" }
   window(:title => "Window Events", :resizable => false) {
      start { |n| para "Window: #{n}\n" }
      hover { |n| para "Window (hover): #{n}\n" }
      leave { |n| para "Window (leave): #{n}\n" }
   }
   dialog(:title => "Dialog Events", :resizable => false) {
      start { |n| para "Dialog: #{n}\n" }
      stack {
         start { |n| para "Stack: #{n}\n" }
         finish { |n| alert "Stack: #{n}\n" }
         hover { |n| para "Stack (hover): #{n}\n" }
         leave { |n| para "Stack (leave): #{n}\n" }
         para "Hover over me!"
      }
   }
}

IanTrudel avatar Jan 14 '15 00:01 IanTrudel

The manual does discuss some of the odd behavior for how, when and why Shoes sets self. Hello->Rules. Changing those rules would require a lot of work, breaks compatibility with Shoes 2, 3, and (probably) 4. It might be easier to resurrect the WxRuby & WxSugar projects.

ccoupe avatar Jan 14 '15 02:01 ccoupe

Thank you for the reference. Your assessment is correct.

The manual section Hello->Rules doesn't make much sense to me. The approach taken by Shoes is flat in the hope to keep certain objects alive and breaks what would otherwise be normal Ruby behaviour. This unfortunately makes it necessary to create variables to access objects in their own block. It seems to be both a design feature and a design flaw.

Requires further investigation.

IanTrudel avatar Jan 14 '15 03:01 IanTrudel

Shoes only looks like Ruby! Repeat. Shoes only looks like Ruby! I imagine many of the newer Ruby meta-programming facilities will fail spectacularly in Shoes. Shoes is not Ruby. Shoes is not Ruby. Shoe is not ...

That part of the manual should warn experienced Rubyists more forcefully that Shoes is different. But even experienced people don't read the manual until something fails.

ccoupe avatar Jan 14 '15 03:01 ccoupe

That part of the manual should warn experienced Rubyists more forcefully that Shoes is different. But even experienced people don't read the manual until something fails.

I read it before but the implications were unclear at that time. Reading it again now that you provided a context proved challenging. I had to read it few times to fully understand what was going on. Sometimes the manual is prettier than useful. It would be really good with additional clarifications and better outline of what can do what, e.g. Shoes.app has access only to a subset of styles.

IanTrudel avatar Jan 14 '15 05:01 IanTrudel