2

質問:靴を使用した「入力時にフィルター」ドロップダウン コントロールの例を持っている人はいますか?

例:私が話していることの例を探している場合は、これらを参照してください。

4

2 に答える 2

2

野生で見たことがない。これは、気が散る前にしばらく前に作業を開始したコードです。非常に大雑把ですが、ここから取得できます。

class Dropdown < Widget
  def initialize (list, opts = {})
    @max_items = opts[:max_items] || 5
    @min_letters = opts[:min_letters] || 3
    @width = opts[:width] || 280
    @fill = opts[:background] || white
    @highlight = opts[:highlight] || yellow
    @match_anywhere = opts[:match_anywhere].nil? ? true : opts[:match_anywhere]
    @ignore_case = opts[:ignore_case].nil? ? true : opts[:ignore_case]
    @entries = list
      @text_box = edit_line :width => @width do |box|
        if box.text.length >= @min_letters
          update_list(box.text)
        else
          @list.clear if @list
          @list = nil
        end
      end
  end

  def update_list(search)
    search.downcase! if @ignore_case
    choices = []
    @entries.collect do |x|
      temp = @ignore_case ? x.downcase : x
      if @match_anywhere
        choices << x if temp.include?(search)
      else 
        choices << x if temp.index(search) == 0
      end
      break if choices.length == @max_items
    end
    @list.clear if @list
    @list = nil
    app.append do
      @list = stack :width => @width do 
        background @fill
        choices.each do |choice| 
          f = flow { para choice }
          f.click do 
            @text_box.text = choice
            @list.clear if @list
            @list = nil
          end
          f.hover {|h| h.contents.first.fill = @highlight }
          f.leave {|l| l.contents.first.fill = nil }
        end
      end
    end unless choices.nil?
    @list.move(0,0)
    @list.displace(0, @text_box.height + @text_box.top)
  end

end

Shoes.app(:width => 500, :height => 500) do
  dropdown ['Breed', 'Green', 'Greetings', 'Phoning', 'Ponies', 'Reed', 'Trees'], {:max_items => 3}
  para 'Ponies are awesome!'
  para 'Bananas are yellow.'
  para 'Sometimes I like to eat bananas, but never ponies.'
end
于 2009-07-04T22:58:51.023 に答える
1

実際の選択ボックスに基づいて、オプションテキストの途中で一致する「jqueryオプションフィルター」を試してください: http://plugins.jquery.com/project/jquery_options_filter

ディイズムのために

于 2009-09-14T06:41:08.597 に答える