Sha256: 2d9a5b67dfbf1fa8283bc9273f2bf9aa7e89a4367ea18dafbe289cf3ace0b34d

Contents?: true

Size: 883 Bytes

Versions: 3

Compression:

Stored size: 883 Bytes

Contents

module RubyApp

  module Elements

    module Lists
      require 'ruby_app/elements/list'

      class Select < RubyApp::Elements::List

        template_path(:all, File.dirname(__FILE__))

        exclude_parent_template(:html, :css, :js)

        attr_accessor :selected_index, :selected_item

        def initialize
          super
        end

        def selected_index=(index)
          @selected_index = index
          @selected_item = @items[index]
        end

        def selected_item=(item)
          @selected_index = @items.index(item)
          @selected_item = @selected_index ? @items[@selected_index] : nil
        end

        protected

          def on_clicked(event)
            @selected_index = event.index
            @selected_item = event.item
            event.update_element(self)
            super(event)
          end

      end

    end

  end

end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
RubyApp-0.0.11 lib/ruby_app/elements/lists/select.rb
RubyApp-0.0.10 lib/ruby_app/elements/lists/select.rb
RubyApp-0.0.9 lib/ruby_app/elements/lists/select.rb