我的鞋子应用程序将三个项目按顺序堆叠在一起(当然是一堆):
- 横幅
- 编辑框
- 流程中的两个按钮
我想要做的是让横幅保持其默认大小(48px)和按钮(我认为这可能是特定于平台的?)并让编辑框占据屏幕上的剩余区域,并自动随窗口调整大小?这可能吗?
如果没有,如果将按钮移到编辑框上方是否可以? (因此编辑框将填充到窗口底部)
最佳答案
我不能完全相信这一点,因为它的灵感来自于此 email thread以及该线程中链接的代码,但以下内容有效;虽然很粗糙(它每秒轮询窗口以调整大小)。
Shoes.app do
@header = stack :height => 48 do
background red
end
stack do
@edit = edit_box
end
@footer = flow do
style(:attach => Window, :top => app.height-100, :height => 25)
button "Button 1"
button "Button 2"
end
@height = 0
every(1) do
@windowheight = slot.height
# Note app.height works on Linux and Windows, but not on OSX
# See http://article.gmane.org/gmane.comp.lib.shoes/3493/match=app+height
# So use slot.height instead.
unless @windowheight == @height
@edit.style(:height => @<a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="27504e494348504f424e404f530a674f4246434255094f424e404f530a" rel="noreferrer noopener nofollow">[email protected]</a>@footer.height)
@footer.style(:top => @windowheight-25)
end
end
end
据我所知,如果您移动编辑框上方的按钮,您仍然需要执行相同的操作才能动态调整其大小。不过,您可以询问一个新的鞋子邮件列表:[email protected]
关于ruby - 编辑框自动高度,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1732947/