public class IlvEventBehavior extends IlvSingleBehavior implements IlvInteractiveBehavior
IlvEventBehavior
is used to handle user events in a
prototype.
An event behavior handles input events of a given type (for example, mouse clicked) in an element of the prototype or in the whole prototype. You can specify a Boolean expression to filter events depending on the modifiers (mouse button or key). When an event occurs, the property to which the event behavior is attached is set to an expression. This expression can combine constants, other properties, and special variables containing the details of the event: x/y coordinates, key code, modifiers.
Constructor and Description |
---|
IlvEventBehavior(IlvEventBehavior source)
Creates a new behavior object by copying an existing one.
|
IlvEventBehavior(IlvInputStream in)
Reads the behavior from an
IlvInputStream stream. |
IlvEventBehavior(String name,
String elementName,
int eventID,
String filterExpression,
String dataExpression)
Creates a new event behavior object.
|
Modifier and Type | Method and Description |
---|---|
protected void |
attach(IlvGroup group)
This method is overridden to set an
IlvGroupInteractor on the
element(s) for which events are handled. |
IlvBehavior |
copy()
Returns a copy of the behavior.
|
String |
getDataExpression()
Gets the
dataExpression parameter for this behavior object. |
String |
getElementName()
Gets the
elementName parameter for this behavior object. |
int |
getEventID()
Gets the
eventID parameter for this behavior object. |
String |
getFilterExpression()
Gets the
filterExpression parameter for this behavior object. |
boolean |
processEvent(IlvGroup group,
IlvGraphicElement element,
AWTEvent event,
IlvObjectInteractorContext context)
Implementation of the
IlvInteractiveBehavior interface:
handles events that match the type and filter expression passed to the
constructor. |
void |
setDataExpression(String dataExpression)
Sets the
dataExpression parameter for this behavior object. |
void |
setElementName(String elementName)
Sets the
elementName parameter for this behavior object. |
void |
setEventID(int eventID)
Sets the
eventID parameter for this behavior object. |
void |
setFilterExpression(String filterExpression)
Sets the
filterExpression parameter for this behavior object. |
String |
toString()
Returns a short text describing this behavior object.
|
void |
write(IlvOutputStream out)
Writes the behavior to an
IlvOutputStream . |
get, get, getName, getValueNames, set, set, setName
detach, getParameter, isOutput, isReadable, isWritable
public IlvEventBehavior(String name, String elementName, int eventID, String filterExpression, String dataExpression)
name
- the name of the behavior object. When an event that matches the
eventID
and filterExpression
parameters
occurs in the element designated by elementName
, the
property name
will be set to the expression
dataExpression
.elementName
- the name of the element in which the event must occur. This
parameter can be set to "[all]"
to handle events in
the whole prototype.eventID
- the type of events to handle. The type must correspond to an event
represented by a subclass of
java.awt.event.InputEvent
. The type can be 0 to
indicate that all input events must be handled.filterExpression
- the expression used to filter events. The filter expression is
evaluated, and the event is handled only if the result is true.
This expression can contain constants, other properties of the
prototype, and also the following special variables that contain
the event's fields:
eventID
- the integer ID of the event. The
possible event IDs are also predefined as variables that can be
used in the expression (for example,
eventID == MOUSE_PRESSED
).
button1Down
- contains true
if the
first mouse button was down when the event occurred.
button2Down
- contains true
if the
second mouse button was down when the event occurred.
button3Down
- contains true
if the
third mouse button was down when the event occurred.
altDown
- contains true
if the Alt
modifier key was down when the event occurred.
altGraphDown
- contains true
if the
AltGraph modifier key was down when the event occurred.
controlDown
- contains true
if the
Control modifier key was down when the event occurred.
metaDown
- contains true
if the Meta
modifier key was down when the event occurred.
shiftDown
- contains true
if the
Shift modifier key was down when the event occurred.
eventX
- contains the X coordinate of the event
(for mouse events only).
eventY
- contains the Y coordinate of the event
(for mouse events only).
clickCount
- contains the click count of the
event (for mouse events only).
eventKey
- contains the key code as a String; for
example, "A" or "F10" (for key events only).
dataExpression
- the expression to which the property will be set when a matching
event occurs. This expression can contain constants, other
properties of the prototype, and also the special variables listed
above.public IlvEventBehavior(IlvEventBehavior source)
source
- the behavior object to be copied.public IlvEventBehavior(IlvInputStream in) throws IlvReadFileException
IlvInputStream
stream. This
constructor must be called by the input constructors of subclasses.in
- The input stream.IlvReadFileException
- if the stream format is not correct.public void write(IlvOutputStream out) throws IOException
IlvOutputStream
.write
in interface IlvPersistentObject
write
in class IlvSingleBehavior
out
- The output stream.IOException
- thrown when an exception occurs during
the write operation for this object.public IlvBehavior copy()
copy
in class IlvBehavior
public String toString()
toString
in class IlvBehavior
protected void attach(IlvGroup group)
IlvGroupInteractor
on the
element(s) for which events are handled.attach
in class IlvBehavior
group
- the group to which this behavior object is attached.IlvGroup.addBehavior(ilog.views.prototypes.IlvBehavior)
public void setElementName(String elementName)
elementName
parameter for this behavior object.public String getElementName()
elementName
parameter for this behavior object.public void setEventID(int eventID)
eventID
parameter for this behavior object.public int getEventID()
eventID
parameter for this behavior object.public void setFilterExpression(String filterExpression)
filterExpression
parameter for this behavior object.public String getFilterExpression()
filterExpression
parameter for this behavior object.public void setDataExpression(String dataExpression)
dataExpression
parameter for this behavior object.public String getDataExpression()
dataExpression
parameter for this behavior object.public boolean processEvent(IlvGroup group, IlvGraphicElement element, AWTEvent event, IlvObjectInteractorContext context)
IlvInteractiveBehavior
interface:
handles events that match the type and filter expression passed to the
constructor.processEvent
in interface IlvInteractiveBehavior
group
- the group containing the element in which the event occurred.element
- the graphic element in which the event occurred.event
- the event, which can be a MouseEvent
or a
KeyEvent
.context
- the interactor context, which can be used to get the view
transformer.true
if the event was actually processed, or
false
if the event was ignored.© Copyright 2024 Rogue Wave Software, Inc., a Perforce company.. All Rights Reserved.