Sha256: 88bc78492a56ca1c88a2ee6e41d6998d1e42a0b62b4e1fae8b233048eec95c5a
Contents?: true
Size: 889 Bytes
Versions: 2
Compression:
Stored size: 889 Bytes
Contents
# frozen_string_literal: true class Scarpe class Button < Scarpe::Widget include Scarpe::Log display_properties :text, :width, :height, :top, :left, :color, :padding_top, :padding_bottom, :text_color, :size, :font_size def initialize(text, width: nil, height: nil, top: nil, left: nil, color: nil, padding_top: nil, padding_bottom: nil, size: 12, text_color: nil, font_size: nil, & block) log_init("Button") # Properties passed as positional args, not keywords, don't get auto-set @text = text @color = color @block = block super # Bind to a handler named "click" bind_self_event("click") do @log.debug("Button clicked, calling handler") if @block @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 | lib/scarpe/button.rb |
scarpe-0.2.0 | lib/scarpe/button.rb |