Sha256: bd5ac046c90be995a6ef435d4b6f995f0074291c5d94ad82bd3488e63a40a3d3

Contents?: true

Size: 579 Bytes

Versions: 6

Compression:

Stored size: 579 Bytes

Contents

module UI
  def self.alert(opt={}, &block)
    alert = UI::Alert.new
    alert.title = (opt[:title] or raise ":title needed")
    alert.message = (opt[:message] or raise ":message needed")

    buttons = [:cancel, :default]
    has_button = false
    buttons.each do |button|
      if title = opt[button]
        alert.set_button(title, button)
        has_button = true
      end
    end
    alert.set_button('Cancel', :cancel) unless has_button

    alert.show(&block)
    @last_alert = alert # Keep a strong reference to the alert object has it has to remain alive.
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
motion-flow-0.1.8 flow/ui/alert.rb
motion-flow-0.1.7 flow/ui/alert.rb
motion-flow-0.1.6 flow/ui/alert.rb
motion-flow-0.1.5 flow/ui/alert.rb
motion-flow-0.1.4 flow/ui/alert.rb
motion-flow-0.1.3 flow/ui/alert.rb