Sha256: de9e17afd901e630b774f783dcc0b5892960f6decc9cf2b8509f7989a459bc19

Contents?: true

Size: 623 Bytes

Versions: 7

Compression:

Stored size: 623 Bytes

Contents

module Luck
class Alert < Pane
  attr_accessor :width, :height, :handler
  
  def initialize display, width, height, title, controls={}, &blck
    super display, nil, nil, nil, nil, title, controls, &blck
    
    @width, @height = width, height
  end
  
  def x1
    (@display.width / 2).to_i - (@width / 2).to_i
  end
  def y1
    (@display.height / 2).to_i - (@height / 2).to_i
  end
  
  def x2
    x1 + @width
  end
  def y2
    y1 + @height
  end
  
  def on_dismiss &blck
    @handler = blck
  end
  
  def handle_char char
    if char == "\n"
      @handler.call @text if @handler
    end
    #redraw
  end
end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
luck-0.1.6 lib/luck/alert.rb
luck-0.1.5 lib/luck/alert.rb
luck-0.1.4 lib/luck/alert.rb
luck-0.1.3 lib/luck/alert.rb
luck-0.1.2 lib/luck/alert.rb
luck-0.1.1 lib/luck/alert.rb
luck-0.1.0 lib/luck/alert.rb