Method: Fidgit::Button#initialize
- Defined in:
- lib/fidgit/elements/button.rb
#initialize(text, options = {}, &block) ⇒ Button
Returns a new instance of Button.
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/fidgit/elements/button.rb', line 8 def initialize(text, = {}, &block) = { color: default(:color), background_color: default(:background_color), border_color: default(:border_color), shortcut_color: default(:shortcut_color), shortcut: nil, }.merge! @shortcut_color = [:shortcut_color].dup @shortcut = if [:shortcut] == :auto raise ArgumentError.new("Can't use :auto for :shortcut without text") if text.empty? text[0].downcase.to_sym else [:shortcut] end raise ArgumentError.new(":shortcut must be a symbol") unless @shortcut.nil? or @shortcut.is_a? Symbol super(text, ) self.text = text # Force shortcut to be written out properly. update_colors end |