Sha256: d59f0f3ecb6ab979b67b9f6ee15a94ad33d91723974f28fed5e131b6a15fed3c

Contents?: true

Size: 617 Bytes

Versions: 2

Compression:

Stored size: 617 Bytes

Contents

# frozen_string_literal: true

class Scarpe
  class <%= argument %> < Scarpe::Widget
     display_properties <%= display_properties %> # Write your display proporties here

    def initialize(text, width: nil, height: nil, top: nil, left: nil, &block)
      # Properties passed as positional args, not keywords, don't get auto-set
      @text = text
      @block = block

      super

      # Bind to a handler named "click"
      bind_self_event("click") do
        @block&.call
      end

      create_display_widget
    end

    # Set the click handler
    def click(&block)
      @block = block
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
scarpe-0.2.1 templates/class_template_with_event_bind.erb
scarpe-0.2.0 templates/class_template_with_event_bind.erb