Sha256: 67a952ea83c59b2ffb31016e57e27df63f547da93eceedfa6c72d694c247c260

Contents?: true

Size: 1.49 KB

Versions: 9

Compression:

Stored size: 1.49 KB

Contents

module CyberarmEngine
  class Element
    class CheckBox < Flow
      def initialize(text, options, block = nil)
        super({}, block = nil)
        options[:toggled] = options[:checked]

        @toggle_button = ToggleButton.new(options)
        @label         = Label.new(text, options)

        define_label_singletons

        add(@toggle_button)
        add(@label)
      end

      def text=(text)
        @label.text = text
        recalculate
      end

      def value
        @toggle_button.value
      end

      def value=(bool)
        @toggle_button.vlaue = bool
      end

      def define_label_singletons
        @label.define_singleton_method(:_toggle_button) do |button|
          @_toggle_button = button
        end

        @label._toggle_button(@toggle_button)

        @label.define_singleton_method(:holding_left_mouse_button) do |sender, x, y|
          @_toggle_button.left_mouse_button(sender, x, y)
        end

        @label.define_singleton_method(:released_left_mouse_button) do |sender, x, y|
          @_toggle_button.released_left_mouse_button(sender, x, y)
        end

        @label.define_singleton_method(:clicked_left_mouse_button) do |sender, x, y|
          @_toggle_button.clicked_left_mouse_button(sender, x, y)
        end

        @label.define_singleton_method(:enter) do |sender|
          @_toggle_button.enter(sender)
        end

        @label.define_singleton_method(:leave) do |sender|
          @_toggle_button.leave(sender)
        end
      end
    end
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
cyberarm_engine-0.13.1 lib/cyberarm_engine/ui/elements/check_box.rb
cyberarm_engine-0.12.1 lib/cyberarm_engine/ui/elements/check_box.rb
cyberarm_engine-0.12.0 lib/cyberarm_engine/ui/elements/check_box.rb
cyberarm_engine-0.11.1 lib/cyberarm_engine/ui/elements/check_box.rb
cyberarm_engine-0.11.0 lib/cyberarm_engine/ui/elements/check_box.rb
cyberarm_engine-0.10.2 lib/cyberarm_engine/ui/elements/check_box.rb
cyberarm_engine-0.10.1 lib/cyberarm_engine/ui/elements/check_box.rb
cyberarm_engine-0.10.0 lib/cyberarm_engine/ui/elements/check_box.rb
cyberarm_engine-0.9.0 lib/cyberarm_engine/ui/elements/check_box.rb