English 中文(简体)
Automatic height of edit box
原标题:

My shoes application has three items stacked on top of each other (with a stack, of course), in order:

  • A banner
  • An edit box
  • Two buttons in a flow

What I want to do is have the banner stay at it s default size (48px) and the buttons as well (I think this may be platform specific?) and have the edit box take up the remaining area on screen, and automatically resize with the window? Is this possible?

If not, would it be possible if the buttons were moved above the edit box? (So the edit box would fill to the bottom of the window)

最佳回答

I can t take full credit for this, as it is inspired by this email thread and code linked in that thread, but the below works; although is crude (it polls the window every second in order to adjust sizes).

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 => @windowheight-@header.height-@footer.height)
            @footer.style(:top => @windowheight-25)
        end
    end
end

As far as I know, if you moved the buttons above the edit box, you would still have to do the same kind of thing in order to have it dynamically resize. There is a new mailing list for Shoes you could ask on though: shoes@librelist.com

问题回答

暂无回答




相关问题
Ruby parser in Java

The project I m doing is written in Java and parsers source code files. (Java src up to now). Now I d like to enable parsing Ruby code as well. Therefore I am looking for a parser in Java that parses ...

rails collection_select vs. select

collection_select and select Rails helpers: Which one should I use? I can t see a difference in both ways. Both helpers take a collection and generates options tags inside a select tag. Is there a ...

RubyCAS-Client question: Rails

I ve installed RubyCAS-Client version 2.1.0 as a plugin within a rails app. It s working, but I d like to remove the ?ticket= in the url. Is this possible?

Ordering a hash to xml: Rails

I m building an xml document from a hash. The xml attributes need to be in order. How can this be accomplished? hash.to_xml

multiple ruby extension modules under one directory

Can sources for discrete ruby extension modules live in the same directory, controlled by the same extconf.rb script? Background: I ve a project with two extension modules, foo.so and bar.so which ...

Text Editor for Ruby-on-Rails

guys which text editor is good for Rubyonrails? i m using Windows and i was using E-Texteditor but its not free n its expired now can anyone plese tell me any free texteditor? n which one is best an ...

热门标签