<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>
Module: Responder2
— FXRuby API Documentation
</title>
<link rel="stylesheet" href="css/style.css" type="text/css" />
<link rel="stylesheet" href="css/common.css" type="text/css" />
<script type="text/javascript">
pathId = "Responder2";
relpath = '';
</script>
<script type="text/javascript" charset="utf-8" src="js/jquery.js"></script>
<script type="text/javascript" charset="utf-8" src="js/app.js"></script>
</head>
<body>
<div class="nav_wrap">
<iframe id="nav" src="class_list.html?1"></iframe>
<div id="resizer"></div>
</div>
<div id="main" tabindex="-1">
<div id="header">
<div id="menu">
<a href="_index.html">Index (R)</a> »
<span class="title">Responder2</span>
</div>
<div id="search">
<a class="full_list_link" id="class_list_link"
href="class_list.html">
<svg width="24" height="24">
<rect x="0" y="4" width="24" height="4" rx="1" ry="1"></rect>
<rect x="0" y="12" width="24" height="4" rx="1" ry="1"></rect>
<rect x="0" y="20" width="24" height="4" rx="1" ry="1"></rect>
</svg>
</a>
</div>
<div class="clear"></div>
</div>
<div id="content"><h1>Module: Responder2
</h1>
<div class="box_info">
<dl>
<dt>Included in:</dt>
<dd><span class='object_link'><a href="Fox/FXDataTarget.html" title="Fox::FXDataTarget (class)">Fox::FXDataTarget</a></span>, <span class='object_link'><a href="Fox/FXRecentFiles.html" title="Fox::FXRecentFiles (class)">Fox::FXRecentFiles</a></span>, <span class='object_link'><a href="Fox/FXWindow.html" title="Fox::FXWindow (class)">Fox::FXWindow</a></span></dd>
</dl>
<dl>
<dt>Defined in:</dt>
<dd>lib/fox16/responder2.rb</dd>
</dl>
</div>
<h2>Overview</h2><div class="docstring">
<div class="discussion">
<p>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).</p>
</div>
</div>
<div class="tags">
</div>
<h2>
Instance Method Summary
<small><a href="#" class="summary_toggle">collapse</a></small>
</h2>
<ul class="summary">
<li class="public ">
<span class="summary_signature">
<a href="#connect-instance_method" title="#connect (instance method)">#<strong>connect</strong>(message_type, callable_object = nil, &block) ⇒ Object </a>
</span>
<span class="summary_desc"><div class='inline'>
<p>Assign a “handler” for all FOX messages of type <em>messageType</em> sent from this widget.</p>
</div></span>
</li>
</ul>
<div id="instance_method_details" class="method_details_list">
<h2>Instance Method Details</h2>
<div class="method_details first">
<h3 class="signature first" id="connect-instance_method">
#<strong>connect</strong>(message_type, callable_object = nil, &block) ⇒ <tt>Object</tt>
</h3><div class="docstring">
<div class="discussion">
<p>Assign a “handler” for all FOX messages of type <em>messageType</em> sent from this widget. When called with only one argument, a block is expected, e.g.</p>
<pre class="code ruby"><code class="ruby">aButton.connect(SEL_COMMAND) { |sender, selector, data|
... code to handle this event ...
}
</code></pre>
<p>The arguments passed into the block are the <em>sender</em> of the message (i.e. the widget), the <em>selector</em> for the message, and any message-specific <em>data</em>.</p>
<p>When #connect is called with two arguments, the second argument should be some callable object such as a Method or Proc instance, e.g.</p>
<pre class="code ruby"><code class="ruby"><span class='id identifier rubyid_aButton'>aButton</span><span class='period'>.</span><span class='id identifier rubyid_connect'>connect</span><span class='lparen'>(</span><span class='const'>SEL_COMMAND</span><span class='comma'>,</span> <span class='id identifier rubyid_method'>method</span><span class='lparen'>(</span><span class='symbol'>:onCommand</span><span class='rparen'>)</span><span class='rparen'>)</span>
</code></pre>
<p>As with the one-argument form of #connect, the callable object will be “called” with three arguments (the sender, selector and message data).</p>
</div>
</div>
<div class="tags">
</div><table class="source_code">
<tr>
<td>
<pre class="lines">
106
107
108
109
110
111
112</pre>
</td>
<td>
<pre class="code"><span class="info file"># File 'lib/fox16/responder2.rb', line 106</span>
<span class='kw'>def</span> <span class='id identifier rubyid_connect'>connect</span><span class='lparen'>(</span><span class='id identifier rubyid_message_type'>message_type</span><span class='comma'>,</span> <span class='id identifier rubyid_callable_object'>callable_object</span><span class='op'>=</span><span class='kw'>nil</span><span class='comma'>,</span> <span class='op'>&</span><span class='id identifier rubyid_block'>block</span><span class='rparen'>)</span>
<span class='kw'>unless</span> <span class='id identifier rubyid_instance_variables'>instance_variables</span><span class='period'>.</span><span class='id identifier rubyid_include?'>include?</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>@pseudoTarget</span><span class='tstring_end'>'</span></span><span class='rparen'>)</span> <span class='op'>||</span> <span class='id identifier rubyid_instance_variables'>instance_variables</span><span class='period'>.</span><span class='id identifier rubyid_include?'>include?</span><span class='lparen'>(</span><span class='symbol'>:@pseudoTarget</span><span class='rparen'>)</span>
<span class='ivar'>@pseudoTarget</span> <span class='op'>=</span> <span class='const'><span class='object_link'><a href="Fox.html" title="Fox (module)">Fox</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="Fox/FXPseudoTarget.html" title="Fox::FXPseudoTarget (class)">FXPseudoTarget</a></span></span><span class='period'>.</span><span class='id identifier rubyid_new'><span class='object_link'><a href="Fox/FXPseudoTarget.html#initialize-instance_method" title="Fox::FXPseudoTarget#initialize (method)">new</a></span></span>
<span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_target'>target</span> <span class='op'>=</span> <span class='ivar'>@pseudoTarget</span>
<span class='kw'>end</span>
<span class='ivar'>@pseudoTarget</span><span class='period'>.</span><span class='id identifier rubyid_pconnect'>pconnect</span><span class='lparen'>(</span><span class='id identifier rubyid_message_type'>message_type</span><span class='comma'>,</span> <span class='id identifier rubyid_callable_object'>callable_object</span> <span class='op'>?</span> <span class='id identifier rubyid_callable_object'>callable_object</span> <span class='op'>:</span> <span class='id identifier rubyid_block'>block</span><span class='rparen'>)</span>
<span class='kw'>end</span></pre>
</td>
</tr>
</table>
</div>
</div>
</div>
<div id="footer">
Generated on Fri Nov 27 21:10:34 2020 by
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
0.9.24 (ruby-2.7.2).
</div>
</div>
</body>
</html>