Sha256: f56c0a949b0928f769ea8edf8e51acd48788b1f3514f36f5b6960420b8a67948

Contents?: true

Size: 1.39 KB

Versions: 10

Compression:

Stored size: 1.39 KB

Contents

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

        options[:parent] = self
        @toggle_button = ToggleButton.new(options)

        options[:parent] = self
        @label = TextBlock.new(text, options)

        @label.subscribe(:holding_left_mouse_button) do |sender, x, y|
          @toggle_button.left_mouse_button(sender, x, y)
        end

        @label.subscribe(:released_left_mouse_button) do |sender, x, y|
          @toggle_button.released_left_mouse_button(sender, x, y)
        end

        @label.subscribe(:clicked_left_mouse_button) do |sender, x, y|
          @toggle_button.clicked_left_mouse_button(sender, x, y)
          publish(:changed, @toggle_button.value)
        end

        @label.subscribe(:enter) do |sender|
          @toggle_button.enter(sender)
        end

        @label.subscribe(:leave) do |sender|
          @toggle_button.leave(sender)
        end

        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.value = bool
        publish(:changed, @toggle_button.value)
      end
    end
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
cyberarm_engine-0.24.4 lib/cyberarm_engine/ui/elements/check_box.rb
cyberarm_engine-0.24.3 lib/cyberarm_engine/ui/elements/check_box.rb
cyberarm_engine-0.24.2 lib/cyberarm_engine/ui/elements/check_box.rb
cyberarm_engine-0.24.1 lib/cyberarm_engine/ui/elements/check_box.rb
cyberarm_engine-0.24.0 lib/cyberarm_engine/ui/elements/check_box.rb
cyberarm_engine-0.23.0 lib/cyberarm_engine/ui/elements/check_box.rb
cyberarm_engine-0.22.0 lib/cyberarm_engine/ui/elements/check_box.rb
cyberarm_engine-0.21.0 lib/cyberarm_engine/ui/elements/check_box.rb
cyberarm_engine-0.20.0 lib/cyberarm_engine/ui/elements/check_box.rb
cyberarm_engine-0.19.1 lib/cyberarm_engine/ui/elements/check_box.rb