Class: Canis::Action
Overview
encapsulates behaviour allowing centralization
Example
a = Action.new("&New Row") { commands }
a.accelerator "Alt N"
menu.add(a)
b = Button.new form do
action a
...
end
Instance Attribute Summary collapse
-
#accelerator ⇒ Object
Returns the value of attribute accelerator.
-
#enabled ⇒ Object
Returns the value of attribute enabled.
-
#help_text ⇒ Object
Returns the value of attribute help_text.
-
#mnemonic ⇒ Object
Returns the value of attribute mnemonic.
-
#name ⇒ Object
once again commented on 2014-04-28 - 14:37 to keep simple include EventHandler # removed 2012-01-3 maybe you can bind FIRE include ConfigSetup # removed 2012-01-3 name used on button or menu.
-
#tooltip_text ⇒ Object
Returns the value of attribute tooltip_text.
Instance Method Summary collapse
-
#action ⇒ Object
to adapt this to CMenuitems.
- #call(*args) ⇒ Object
-
#hotkey ⇒ Object
the next 3 are to adapt this to CMenuitems.
-
#initialize(name, config = {}, &block) ⇒ Action
constructor
A new instance of Action.
-
#label ⇒ Object
to adapt this to CMenuitems.
Constructor Details
#initialize(name, config = {}, &block) ⇒ Action
Returns a new instance of Action.
42 43 44 45 46 47 48 49 50 51 52 53 54 55 |
# File 'lib/canis/core/include/action.rb', line 42 def initialize name, config={}, &block super &block @name = name @name.freeze @enabled = true # removing dependency from config #config_setup config # @config.each_pair { |k,v| variable_set(k,v) } @config = config keys = @config.keys keys.each do |e| variable_set(e, @config[e]) end #@_events = [:FIRE] end |
Instance Attribute Details
#accelerator ⇒ Object
Returns the value of attribute accelerator.
40 41 42 |
# File 'lib/canis/core/include/action.rb', line 40 def accelerator @accelerator end |
#enabled ⇒ Object
Returns the value of attribute enabled.
36 37 38 |
# File 'lib/canis/core/include/action.rb', line 36 def enabled @enabled end |
#help_text ⇒ Object
Returns the value of attribute help_text.
38 39 40 |
# File 'lib/canis/core/include/action.rb', line 38 def help_text @help_text end |
#mnemonic ⇒ Object
Returns the value of attribute mnemonic.
39 40 41 |
# File 'lib/canis/core/include/action.rb', line 39 def mnemonic @mnemonic end |
#name ⇒ Object
once again commented on 2014-04-28 - 14:37 to keep simple include EventHandler # removed 2012-01-3 maybe you can bind FIRE include ConfigSetup # removed 2012-01-3 name used on button or menu
35 36 37 |
# File 'lib/canis/core/include/action.rb', line 35 def name @name end |
#tooltip_text ⇒ Object
Returns the value of attribute tooltip_text.
37 38 39 |
# File 'lib/canis/core/include/action.rb', line 37 def tooltip_text @tooltip_text end |
Instance Method Details
#action ⇒ Object
to adapt this to CMenuitems
77 78 79 |
# File 'lib/canis/core/include/action.rb', line 77 def action self end |
#call(*args) ⇒ Object
56 57 58 59 60 61 |
# File 'lib/canis/core/include/action.rb', line 56 def call *args return unless @enabled # seems to be here, if you've bound :FIRE no this, not on any widget #fire_handler :FIRE, self super end |
#hotkey ⇒ Object
the next 3 are to adapt this to CMenuitems
65 66 67 68 69 70 71 |
# File 'lib/canis/core/include/action.rb', line 65 def hotkey return @mnemonic if @mnemonic ix = @name.index('&') if ix return @name[ix+1, 1].downcase end end |
#label ⇒ Object
to adapt this to CMenuitems
73 74 75 |
# File 'lib/canis/core/include/action.rb', line 73 def label @name.sub('&','') end |