module RuGUI::SignalSupport::ClassMethods
Public Instance Methods
on(widget_name, signal_name, receiver_method_name = nil, &block)
click to toggle source
Declares a signal handler for the given signal of the widget. The handler may be a method of this class or a block, which will be run with the instance of this class as context.
If the signal has arguments they are passed to the receiver method or the block.
# File lib/rugui/signal_support.rb, line 10 def on(widget_name, signal_name, receiver_method_name = nil, &block) if receiver_method_name.nil? and not block_given? logger.warn "Either a block or a receiver_method_name must be given to on(#{widget_name}, #{signal_name}), ignoring call." return end signal_connection = RuGUI::SignalSupport::SignalConnection.new signal_connection.widget_name = widget_name signal_connection.signal_name = signal_name signal_connection.receiver_method_name = receiver_method_name signal_connection.receiver_block = block if block_given? signal_connection.receiver_class = self self.signal_connections << signal_connection end