Sha256: 89d31cb7bdf1538365b3c402bb089f4a60bdab3449720729259419a9aef0afb4

Contents?: true

Size: 475 Bytes

Versions: 2

Compression:

Stored size: 475 Bytes

Contents

# frozen_string_literal: true

class Scarpe
  class EditBox < Scarpe::Widget
    display_properties :text, :height, :width

    def initialize(text = nil, height: nil, width: nil, &block)
      @text = text.nil? ? block&.call : text || ""

      super

      bind_self_event("change") do |new_text|
        self.text = new_text
        @callback&.call(new_text)
      end

      create_display_widget
    end

    def change(&block)
      @callback = block
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
scarpe-0.2.1 lib/scarpe/edit_box.rb
scarpe-0.2.0 lib/scarpe/edit_box.rb