📄 bicommand.html
字号:
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"><html><!--
Generated using api.website.xsl version 2003-07-17
-->
<head>
<META http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>BiCommand</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<link type="text/css" rel="stylesheet" href="api.css"><script type="text/javascript">
function showDerivedClasses() {
var ul = document.getElementById("api-derived-classes");
var lis = ul.childNodes;
var l = lis.length;
for (var i = 1; i < l; i++)
lis[i].style.display = "";
lis[0].style.display = "none";
}
</script></head>
<body>
<h1 id="BiCommand">BiCommand</h1>
<p>
Command objects can be used to make several user interface components
execute the command when they are invoked. Components that use the command
object will be synchronized with the properties of the command. For example,
if a button has a disabled command the button will also be disabled.
</p>
<p>This class extends
<code><a href="BiEventTarget.html">BiEventTarget</a></code>
and therefore all methods and fields available for
<code><a href="BiEventTarget.html">BiEventTarget</a></code>
are also available for <code>BiCommand</code>.</p>
<ul class="partial-class-tree">
<li><code><a href="BiObject.html">BiObject</a></code><ul>
<li><code><a href="BiEventTarget.html">BiEventTarget</a></code><ul><li><code>BiCommand</code><ul id="api-derived-classes"></ul></li></ul></li></ul>
</li>
</ul>
<h2>Constructor</h2>
<p><code>
new BiCommand()</code></p>
<h3>Parameters</h3>
<p>No parameters.</p>
<h2>Properties</h2>
<table>
<thead>
<tr>
<td>Name</td>
<td>Type</td>
<td class="get-header">get</td>
<td class="set-header">set</td>
<td>Descripton</td>
</tr>
</thead>
<tbody>
<tr>
<td><a name="checked"></a><code>checked</code></td>
<td><code class="type">Boolean</code></td>
<td class="get-column"><img src="check.png" alt="checked"></td>
<td class="set-column"><img src="check.png" alt="checked"></td>
<td>
The checked state of the command. This is usually used to synchronize
the checked property of the components using this command (such as
<code><a href="BiRadioButton.html">BiRadioButton</a></code>,
<code><a href="BiCheckBox.html">BiCheckBox</a></code> and others).
</td>
</tr>
<tr>
<td><a name="enabled"></a><code>enabled</code></td>
<td><code class="type">Boolean</code></td>
<td class="get-column"><img src="check.png" alt="checked"></td>
<td class="set-column"><img src="check.png" alt="checked"></td>
<td>
Whether the command is enabled or not
</td>
</tr>
<tr>
<td><a name="keyCode"></a><code>keyCode</code></td>
<td><code class="type">Number</code></td>
<td class="get-column"><img src="check.png" alt="checked"></td>
<td class="set-column"><img src="check.png" alt="checked"></td>
<td>
This gives a bit more detail than the <code><a href="#shortcut">shortcut</a></code> property because
there are cases where there is no name for the key. Use <code><a href="#shortcut">shortcut</a></code>
whenever possible and fall back on keyCode when needed. If keyCode
is provided only the modifiers from the <code><a href="#shortcut">shortcut</a></code> is used.
</td>
</tr>
<tr>
<td><a name="ownerWindow"></a><code>ownerWindow</code></td>
<td><code class="type"><code><a href="BiApplicationWindow.html">BiApplicationWindow</a></code> /
<code><a href="BiWindow.html">BiWindow</a></code></code></td>
<td class="get-column"><img src="check.png" alt="checked"></td>
<td class="set-column"></td>
<td>
If the command has an owner window and a <code><a href="#shortcut">shortcut</a></code> or
a <code><a href="#keyCode">keyCode</a></code> the command will be executed when the user
presses the keys needed to execute the command. To set the
owner window call <code><a href="BiApplicationWindow.html#addCommand">addCommand</a></code>
on the window. By the default the owner window is set to the
<code><a href="BiApplicationWindow.html">application window</a></code>
upon creation.
</td>
</tr>
<tr>
<td><a name="shortcut"></a><code>shortcut</code></td>
<td><code class="type">String</code></td>
<td class="get-column"><img src="check.png" alt="checked"></td>
<td class="set-column"><img src="check.png" alt="checked"></td>
<td>
The keyboard shortcut used to execute the command. The format for
the shortcut is:<br>
<br>
Ctrl+Shift+Alt+k<br>
<br>
You can also use the static fields of <code><a href="BiKeyboardEvent.html">BiKeyboardEvent</a></code>
describing the key codes:
<br>
<br>
Shift+Del
</td>
</tr>
<tr>
<td><a name="userValue"></a><code>userValue</code></td>
<td><code class="type">Object</code></td>
<td class="get-column"><img src="check.png" alt="checked"></td>
<td class="set-column"><img src="check.png" alt="checked"></td>
<td>
The user value of the command. This is usually used to synchronize
the user values of the components using this command (such as
<code><a href="BiRadioGroup.html">BiRadioGroup</a></code> and
<code><a href="BiComboBox.html">BiComboBox</a></code>).
</td>
</tr>
</tbody>
</table>
<h2>Methods</h2>
<table>
<thead>
<tr>
<td>Name</td>
<td>Description</td>
</tr>
</thead>
<tbody>
<tr>
<td><code><a href="#execute">execute</a></code></td>
<td>
Executes the command. This returns <code>false</code> if any event
listener, listening to the <code><a href="#execute">execute</a></code> event, prevented
the default action by calling <code><a href="BiEvent.html">event</a></code>
<code><a href="BiEvent.html#preventDefault">preventDefault</a></code>.
</td>
</tr>
<tr>
<td><code><a href="#matchesKeyboardEvent">matchesKeyboardEvent</a></code></td>
<td>
This method is called by the <code><a href="#ownerWindow">ownerWindow</a></code> when a
keypress event occurs. If the keys pressed match the
<code><a href="#shortcut">shortcut</a></code> property this returns true.
</td>
</tr>
</tbody>
</table>
<h2>Events</h2>
<table>
<thead>
<tr>
<td>Name</td>
<td>Type</td>
<td class="bubbles-header">Bubbles</td>
<td>Descripton</td>
</tr>
</thead>
<tbody>
<tr>
<td><a name="checkedchanged"></a><code>checkedchanged</code></td>
<td><code class="type"><code><a href="BiEvent.html">BiEvent</a></code></code></td>
<td class="bubbles-column"></td>
<td>
This is fired when the <code><a href="#checked">checked</a></code> property is changed.
</td>
</tr>
<tr>
<td><a name="enabledchanged"></a><code>enabledchanged</code></td>
<td><code class="type"><code><a href="BiEvent.html">BiEvent</a></code></code></td>
<td class="bubbles-column"></td>
<td>
This is fired when the <code><a href="#enabled">enabled</a></code> property is changed.
</td>
</tr>
<tr>
<td><a name="execute"></a><code>execute</code></td>
<td><code class="type"><code><a href="BiEvent.html">BiEvent</a></code></code></td>
<td class="bubbles-column"></td>
<td>
This is fired when the command is executed.
</td>
</tr>
<tr>
<td><a name="shortcutchanged"></a><code>shortcutchanged</code></td>
<td><code class="type"><code><a href="BiEvent.html">BiEvent</a></code></code></td>
<td class="bubbles-column"></td>
<td>
This is fired when the <code><a href="#shortcut">shortcut</a></code> property is changed.
</td>
</tr>
<tr>
<td><a name="uservaluechanged"></a><code>uservaluechanged</code></td>
<td><code class="type"><code><a href="BiEvent.html">BiEvent</a></code></code></td>
<td class="bubbles-column"></td>
<td>
This is fired when the <code><a href="#userValue">userValue</a></code> property is changed.
</td>
</tr>
</tbody>
</table>
<h2>Static Methods</h2>
<p>None.</p>
<h2>Static Fields</h2>
<p>None.</p>
<h2>Remarks</h2>
<p>
For the shortcut to work inside an <code><a href="BiWindow.html">internal window</a></code>
you need to add the command to the window using
<code><a href="BiWindow.html#addCommand">addCommand</a></code>.
</p>
<h2>Method Details</h2>
<h3><a name="execute"></a>execute</h3>
<p>
Executes the command. This returns <code>false</code> if any event
listener, listening to the <code><a href="#execute">execute</a></code> event, prevented
the default action by calling <code><a href="BiEvent.html">event</a></code>
<code><a href="BiEvent.html#preventDefault">preventDefault</a></code>.
</p>
<h4>Syntax</h4>
<pre class="method-syntax">object.execute()</pre>
<h4>Parameters</h4>
<p>No arguments.</p>
<h4>Return Type</h4>
<p><code class="type">Boolean</code></p>
<h3><a name="matchesKeyboardEvent"></a>matchesKeyboardEvent</h3>
<p>
This method is called by the <code><a href="#ownerWindow">ownerWindow</a></code> when a
keypress event occurs. If the keys pressed match the
<code><a href="#shortcut">shortcut</a></code> property this returns true.
</p>
<h4>Syntax</h4>
<pre class="method-syntax">object.matchesKeyboardEvent(<span class="methodArgument">e</span>)</pre>
<h4>Parameters</h4>
<table>
<thead>
<tr>
<td>Name</td>
<td>Type</td>
<td class="optional-header">Optional</td>
<td>Default</td>
<td>Descripton</td>
</tr>
</thead>
<tbody>
<tr>
<td><code>e</code></td>
<td><code class="type"><code><a href="BiKeyboardEvent.html">BiKeyboardEvent</a></code></code></td>
<td class="optional-column"></td>
<td></td>
<td></td>
</tr>
</tbody>
</table>
<h4>Return Type</h4>
<p><code class="type">Boolean</code></p>
</body>
</html>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -