Module: Responder2

Included in:
Fox::FXDataTarget, Fox::FXRecentFiles, Fox::FXWindow
Defined in:
lib/fox16/responder2.rb

Overview

The Responder2 module provides the #connect method, which is mixed-in to all classes that have a message target (i.e. Fox::FXDataTarget, Fox::FXRecentFiles and Fox::FXWindow).

Instance Method Summary collapse

Instance Method Details

#connect(message_type, callable_object = nil, &block) ⇒ Object

Assign a “handler” for all FOX messages of type messageType sent from this widget. When called with only one argument, a block is expected, e.g.

aButton.connect(SEL_COMMAND) { |sender, selector, data|
  ... code to handle this event ...
}

The arguments passed into the block are the sender of the message (i.e. the widget), the selector for the message, and any message-specific data.

When #connect is called with two arguments, the second argument should be some callable object such as a Method or Proc instance, e.g.

aButton.connect(SEL_COMMAND, method(:onCommand))

As with the one-argument form of #connect, the callable object will be “called” with three arguments (the sender, selector and message data).



106
107
108
109
110
111
112
# File 'lib/fox16/responder2.rb', line 106

def connect(message_type, callable_object=nil, &block)
  unless instance_variables.include?('@pseudoTarget') || instance_variables.include?(:@pseudoTarget)
    @pseudoTarget = Fox::FXPseudoTarget.new
    self.target = @pseudoTarget
  end
  @pseudoTarget.pconnect(message_type, callable_object ? callable_object : block)
end