In shoes, how do I dock a stack to the bottom of the window?

蹲街弑〆低调 提交于 2019-12-11 03:54:54

问题


In shoes, how would I dock a stack to the bottom of the window?

For example I have the following snippet.

Shoe.app do 
  stack :height => 100 do 
    background red
  end
  stack :height => 100 do 
    background blue
  end
end

I would like the blue stack to dock to the bottom of the window, and stay there whenever I resize the window.


回答1:


To use your example from the mailing list:

Shoes.app do
  @s0 = stack do
    background red
    100.times do
      para "yay"
    end
  end
  @s = stack do
    style(:attach => Window, :top => height - 100)
    background lightblue
    para app.width
    para app.height
  end

  @height = 0
  every(1) do
    unless app.height == @height
      @s.clear do
        background lightblue
        style(:top => height-100)
        para app.width
        para app.height
      end
    end
  end
end

Hi Sam!

Because of the problems I've had with :scroll => true and setting heights (usually a bad idea with the way Shoes is designed), I would do something similar this way:

http://gist.github.com/54431

This way, you'll find that by being attached to a window, scrolling the whole app should work a lot nicer. I tried running this in OSX and the whole sticky fandango failed on me entirely, so I've since booted into linux (which I will assume you are using too). In linux, the mouse scroll wheel works as well, too.

I keep the style in it's own method call, instead of the stack(styles) way of doing it, since for some reason you cannot save the stack to an instance variable if you do so.

Also, you don't need to save the app object, since self is (almost) always Shoes.app, and if it isn't, there's a method called 'app' to get it.

I hope this helps.

http://article.gmane.org/gmane.comp.lib.shoes/2997



来源:https://stackoverflow.com/questions/489558/in-shoes-how-do-i-dock-a-stack-to-the-bottom-of-the-window

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!