ruby - 编辑框自动高度

标签 ruby user-interface shoes

我的鞋子应用程序将三个项目按顺序堆叠在一起(当然是一堆):

  • 横幅
  • 编辑框
  • 流程中的两个按钮

我想要做的是让横幅保持其默认大小(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/

相关文章:

ruby - 为 Windows 创建 Ruby 应用程序

Ruby:从顶部 -n1 输出获取 CPU (un)

ruby-on-rails - Ruby:批量加载对象如何提高内存使用率?

java - 从 JTable 中隐藏行

ruby - 鞋子中的标签运动

ruby - 如何访问 Shoes 中的 'Browse...' 对话框?

ruby-on-rails - 如何在rails中将数据库重置回初始状态?

ruby - 在 Ruby 中对哈希数组的值求和

ios - 我必须为 iPhone 4S 和 5 创建两个 View 吗

linux - * NIX GUI如何工作?