Class: RETerm::Components::Button

Inherits:
RETerm::Component show all
Includes:
RETerm::CDKComponent
Defined in:
lib/reterm/components/button.rb

Overview

CDK Button Component

Direct Known Subclasses

CloseButton

Constant Summary

Constants included from LogHelpers

LogHelpers::LOG_FILE

Instance Attribute Summary collapse

Attributes inherited from RETerm::Component

#activatable, #activate_focus, #highlight_focus, #window

Instance Method Summary collapse

Methods included from RETerm::CDKComponent

#activatable?, #bind_key, #cdk?, #colors=, #component, #deactivate!, #draw!, #early_exit?, #erase, #escape_hit?, #init?, #init_cdk, #normal_exit?, #strip_formatting, #title_attrib=, #value

Methods inherited from RETerm::Component

#activatable?, #activate_focus?, #cdk?, #colored?, #colors=, #deactivate!, #deactivate?, #distance_from, #extra_padding, #finalize!, #highlight_focus?, #reactivate!, #resize, #sync!, #sync_getch

Methods included from KeyBindings

#bind_key, #invoke_key_bindings, #key_bindings, #key_bound?

Methods included from LogHelpers

#logger

Methods included from EventDispatcher

#dispatch, #handle

Constructor Details

#initialize(args = {}) ⇒ Button

Initialize the Button component

Parameters:

  • args (Hash) (defaults to: {})

    button params

Options Hash (args):

  • :title (String)

    title of button



11
12
13
14
# File 'lib/reterm/components/button.rb', line 11

def initialize(args={})
  super
  @title = args[:title] || ""
end

Instance Attribute Details

#titleObject

Returns the value of attribute title.



16
17
18
# File 'lib/reterm/components/button.rb', line 16

def title
  @title
end

Instance Method Details

#activate!Object



35
36
37
38
# File 'lib/reterm/components/button.rb', line 35

def activate!
  dispatch :clicked
  deactivate!
end

#click!Object



40
41
42
# File 'lib/reterm/components/button.rb', line 40

def click!
  activate!
end

#requested_colsObject



31
32
33
# File 'lib/reterm/components/button.rb', line 31

def requested_cols
  @title.size + 1
end

#requested_rowsObject



27
28
29
# File 'lib/reterm/components/button.rb', line 27

def requested_rows
  2
end

#skip_formatting=(b) ⇒ Object



23
24
25
# File 'lib/reterm/components/button.rb', line 23

def skip_formatting=(b)
  component.skip_formatting = b
end