class Canis::Action
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
Attributes
accelerator[RW]
enabled[RW]
help_text[RW]
mnemonic[RW]
name[RW]
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[RW]
Public Class Methods
new(name, config={})
click to toggle source
Calls superclass method
# 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
Public Instance Methods
action()
click to toggle source
to adapt this to CMenuitems
# File lib/canis/core/include/action.rb, line 77 def action self end
call(*args)
click to toggle source
Calls superclass method
# 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()
click to toggle source
the next 3 are to adapt this to CMenuitems
# 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()
click to toggle source
to adapt this to CMenuitems
# File lib/canis/core/include/action.rb, line 73 def label @name.sub('&','') end