class ButtonCounter

Attributes

count[RW]

Public Class Methods

new() click to toggle source
# File examples/button_counter.rb, line 8
def initialize
  @count = 0
end

Public Instance Methods

launch() click to toggle source
# File examples/button_counter.rb, line 12
def launch
  window('Hello, Button!', 190, 20) {
    vertical_box {
      button {
        # data-bind button text to self count, converting to string on read.
        text <= [self, :count, on_read: ->(count) {"Count: #{count}"}]
        
        on_clicked do
          self.count += 1
        end
      }
    }
  }.show
end