📄 fsbuttonevent.java
字号:
/*
* FSButtonEvent.java
* Transform
*
* Copyright (c) 2001-2006 Flagstone Software Ltd. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
*
* * Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
* * Neither the name of Flagstone Software Ltd. nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
* IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
* INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
* OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
* OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package com.flagstone.transform;
import java.util.*;
/**
FSButtonEvent is used to define the actions that a button will execute in response
to a particular event.
<p>The events that a button responds to are:</p>
<table class="datasheet">
<tr><td>RollOver</td><td>occurs when the mouse cursor moves over the active area of a button.</td></tr>
<tr><td>RollOut</td><td>occurs when the mouse cursor moves out of the active area of a button.</td></tr>
<tr><td>Press</td><td>occurs when the mouse button is clicked while the mouse cursor is over the active area of the button.</td></tr>
<tr><td>Release</td><td>occurs when the mouse button is clicked and released while the mouse cursor is over the active area of the button.</td></tr>
<tr><td>DragOut</td><td>occurs when the mouse button is clicked and the mouse cursor is dragged out of the active area of the button.</td></tr>
<tr><td>DragOver</td><td>occurs when the mouse button is clicked, the mouse cursor is dragged into the active area of the button and the mouse button is released.</td></tr>
</td></tr>
</table>
<p>When a button is configured as a menu item (FSDefineButton2 objects only) then three additional events can occur:</p>
<table class="datasheet">
<tr><td>MenuDragOver</td><td>occurs when the mouse button is clicked and the mouse cursor is dragged into the active area of the menu item.</td></tr>
<tr><td>MenuDragOut</td><td>occurs when the mouse button is clicked and the mouse
cursor is dragged out of the active area of the menu item.</td></tr>
<tr><td>ReleaseOut</td><td>occurs when the mouse button is clicked and the mouse cursor is dragged into the active area of the menu item.</td></tr>
</table>
<p>In addition to responding to mouse events, buttons also respond to keys being pressed on the keyboard. Keyboard events are defined by the character key being pressed, e.g. "t", "T", "$", etc. For control keys a number of reserved names are supported:</p>
<table class="datasheet">
<tr><td><Left></td><td>Left arrow key.</td></tr>
<tr><td><Right></td><td>Right arrow key.</td></tr>
<tr><td><Home></td><td>Home key.</td></tr>
<tr><td><End></td><td>End key</td></tr>
<tr><td><Insert></td><td>Insert key.</td></tr>
<tr><td><Delete></td><td>Delete key.</td></tr>
<tr><td><Backspace></td><td>Backspace key.</td></tr>
<tr><td><Enter></td><td>Enter (return) key.</td></tr>
<tr><td><Up></td><td>Up arrow key.</td></tr>
<tr><td><Down></td><td>Down arrow key.</td></tr>
<tr><td><Pageup></td><td>Page up key.</td></tr>
<tr><td><Pagedown></td><td>Page down key.</td></tr>
<tr><td><Tab></td><td>Tab key.</td></tr>
<tr><td><Escape></td><td>Escape key.</td></tr>
<tr><td><Space></td><td>Space bar.</td></tr>
</table>
<p>Since the event code allows multiple events, the code for compound events can be created by performing a bit-wise Or of the individual codes:</p>
<pre>
int eventCode = FSButtonEvent.RollOver | FSButtonEvent.Press;";
</pre>
<p>The class method <b>codeForKey</b> returns the event code that identifies when a specific key is pressed:</p>
<pre>
int eventCode = FSButtonEvent.codeForKey('J');
</pre>
<p>Control keys are identified using one of the reserved ButtonEvent values:</p>
<pre>
int eventCode = FSButtonEvent.Enter | FSButtonEvent.PageUp;
</pre>
<p>However while multiple mouse events can be defined for a button only one keyboard event can be defined.</p>
<table class="datasheet">
<tr><th align="left" colspan="2">Attributes</th></tr>
<tr>
<td><a name="FSButtonEvent_0">event</a></td>
<td>a code identifying the different types of button events that the actions defined in this object will be executed in response to.</td>
</tr>
<tr><td><a name="FSButtonEvent_1">actions</a></td>
<td>An array of action objects that are executed when the events defined in the event code occur.</td>
</tr>
<tr><td><a name="FSButtonEvent_2">encodedActions</a></td>
<td>An array of bytes containing encoded actions can also be set. The encoded actions are typically generated by the parser in the Translate framework. The actions array and encodedActions cannot both be valid at the same time. Accessor methods used to set either of the attributes will set the other to null.</td>
</table>
<h1 class="datasheet">History</h1>
<p>The FSButtonEvent class represents the ButtonCondAction data structure from the Macromedia Flash (SWF) File Format Specification. It was introduced in Flash 3.</p> */
public class FSButtonEvent extends FSTransformObject
{
/** Defines the button event that occurs when the mouse cursor moves over the active area of a button. */
public static final int RollOver = 1;
/** Defines the button event that occurs when the mouse cursor moves out of the active area of a button. */
public static final int RollOut = 2;
/** Defines the button event that occurs when the mouse button is clicked while the mouse cursor is over the active area of the button. */
public static final int Press = 4;
/** Defines the button event that occurs when the mouse button is clicked and released while the mouse cursor is over the active area of the button. */
public static final int Release = 8;
/** Defines the button event that occurs when the mouse button is clicked and the mouse cursor is dragged out of the active area of the button. */
public static final int DragOut = 16;
/** Defines the button event that occurs when the mouse button is clicked and the mouse cursor is dragged into the active area of the button. */
public static final int DragOver = 32;
/** Defines the button event that occurs when the mouse button is clicked, the mouse cursor is dragged into the active area of the button and the mouse button is released. */
public static final int ReleaseOut = 64;
/** Defines the button event that occurs when the mouse button is clicked and the mouse cursor is dragged into the active area of the menu item. */
public static final int MenuDragOver = 128;
/** Defines the button event that occurs when the mouse button is clicked and the mouse cursor is dragged out of the active area of the menu item. */
public static final int MenuDragOut = 256;
/** Defines the button event that occurs when the left arrow key is pressed on the keyboard. */
public static final int Left = 512;
/** Defines the button event that occurs when the right arrow key is pressed on the keyboard. */
public static final int Right = 1024;
/** Defines the button event that occurs when the home key is pressed on the keyboard. */
public static final int Home = 1536;
/** Defines the button event that occurs when the end key is pressed on the keyboard. */
public static final int End = 2048;
/** Defines the button event that occurs when the insert key is pressed on the keyboard. */
public static final int Insert = 2560;
/** Defines the button event that occurs when the delete key is pressed on the keyboard. */
public static final int Delete = 3072;
/** Defines the button event that occurs when the backspace key is pressed on the keyboard. */
public static final int Backspace = 4096;
/** Defines the button event that occurs when the enter key is pressed on the keyboard. */
public static final int Enter = 6656;
/** Defines the button event that occurs when the up arrow key is pressed on the keyboard. */
public static final int Up = 7168;
/** Defines the button event that occurs when the down arrow key is pressed on the keyboard. */
public static final int Down = 7680;
/** Defines the button event that occurs when the page up key is pressed on the keyboard. */
public static final int Pageup = 8192;
/** Defines the button event that occurs when the page down key is pressed on the keyboard. */
public static final int Pagedown = 8704;
/** Defines the button event that occurs when the tab key is pressed on the keyboard. */
public static final int Tab = 9216;
/** Defines the button event that occurs when the escape key is pressed on the keyboard. */
public static final int Escape = 9728;
/** Defines the button event that occurs when the space bar is pressed on the keyboard. */
public static final int Space = 16384;
/** Generates the code identifying a particular event using the name of the event.
@param c a keyboard character.
@return the event code corresponding to the specified event.
*/
public static int codeForKey(char c)
{
return c << 9;
}
private int event = 0;
private ArrayList actions = null;
private byte[] encodedActions = null;
/*
* This constructor is used only then lazily decoding actions.
*/
FSButtonEvent(FSCoder coder, int length)
{
if (coder.context[FSCoder.DecodeActions] == 0)
encodedActions = new byte[length-3];
decode(coder);
}
/**
* Construct an FSButtonEvent object, initalizing it with values
* decoded from an encoded object.
*
* @param coder an FSCoder containing the binary data.
*/
public FSButtonEvent(FSCoder coder)
{
decode(coder);
}
/** Constructs an FSButtonEvent object that defines the array of actions that will be executed when a particular event occurs.
@param aNumber the event code.
@param anArray the array of action objects that will be executed when the specified event(s) occur.
*/
public FSButtonEvent(int aNumber, ArrayList anArray)
{
setEvent(aNumber);
setActions(anArray);
}
/**
* Constructs an FSButtonEvent object that defines the array of actions that
* will be executed when a particular event occurs.
*
* @param aNumber the event code.
* @param bytes an array of encoded action objects.
*/
public FSButtonEvent(int aNumber, byte[] bytes)
{
setEvent(aNumber);
setEncodedActions(bytes);
}
/**
* Constructs an FSButtonEvent object by copying values from an existing object.
*
* @param obj an FSButtonEvent object.
*/
public FSButtonEvent(FSButtonEvent obj)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -