class InteractiveObject
package openfl.display
extends DisplayObject › EventDispatcher
extended by DisplayObjectContainer, SimpleButton, TextField
Available on all platforms
The InteractiveObject class is the abstract base class for all display objects with which the user can interact, using the mouse, keyboard, or other user input device.
You cannot instantiate the InteractiveObject class directly. A call to
the new InteractiveObject()
constructor throws an
ArgumentError
exception.
The InteractiveObject class itself does not include any APIs for rendering content onscreen. To create a custom subclass of the InteractiveObject class, extend one of the subclasses that do have APIs for rendering content onscreen, such as the Sprite, SimpleButton, TextField, or MovieClip classes.
Events:
clear | Dispatched when the user selects 'Clear'(or 'Delete') from the text context menu. This event is dispatched to the object that currently has focus. If the object that currently has focus is a TextField, the default behavior of this event is to cause any currently selected text in the text field to be deleted. |
---|---|
click | Dispatched when a user presses and releases
the main button of the user's pointing device
over the same InteractiveObject. For a click
event to occur, it must always follow this
series of events in the order of occurrence:
mouseDown event, then mouseUp. The target
object must be identical for both of these
events; otherwise the |
contextMenu | Dispatched when a user gesture triggers the context menu associated with this interactive object in an OpenFL application. |
copy | Dispatched when the user activates the platform-specific accelerator key combination for a copy operation or selects 'Copy' from the text context menu. This event is dispatched to the object that currently has focus. If the object that currently has focus is a TextField, the default behavior of this event is to cause any currently selected text in the text field to be copied to the clipboard. |
cut | Dispatched when the user activates the platform-specific accelerator key combination for a cut operation or selects 'Cut' from the text context menu. This event is dispatched to the object that currently has focus. If the object that currently has focus is a TextField, the default behavior of this event is to cause any currently selected text in the text field to be cut to the clipboard. |
doubleClick | Dispatched when a user presses and releases
the main button of a pointing device twice in
rapid succession over the same
InteractiveObject when that object's
The The double-click text selection behavior
of a TextField object is not related to the
|
focusIn | Dispatched after a display object
gains focus. This situation happens when a
user highlights the object with a pointing
device or keyboard navigation. The recipient
of such focus is called the target object of
this event, while the corresponding
InteractiveObject instance that lost focus
because of this change is called the related
object. A reference to the related object is
stored in the receiving object's
|
focusOut | Dispatched after a display object
loses focus. This happens when a user
highlights a different object with a pointing
device or keyboard navigation. The object
that loses focus is called the target object
of this event, while the corresponding
InteractiveObject instance that receives
focus is called the related object. A
reference to the related object is stored in
the target object's
|
gesturePan | Dispatched when the user moves a point of
contact over the InteractiveObject instance
on a touch-enabled device (such as moving a
finger from left to right over a display
object on a mobile phone or tablet with a
touch screen). Some devices might also
interpret this contact as a
Specifically, if a user moves a finger
over an InteractiveObject, the
InteractiveObject instance can dispatch a
Note: See the Multitouch class for environment compatibility information. |
gesturePressAndTap | Dispatched when the user creates a point of contact with an InteractiveObject instance, then taps on a touch-enabled device (such as placing several fingers over a display object to open a menu and then taps one finger to select a menu item on a mobile phone or tablet with a touch screen). Some devices might also interpret this contact as a combination of several mouse events, as well. Specifically, if a user moves a finger
over an InteractiveObject, and then provides
a secondary tap, the InteractiveObject
instance can dispatch a
When handling the properties of the event
object, note that the |
gestureRotate | Dispatched when the user performs a rotation gesture at a point of contact with an InteractiveObject instance (such as touching two fingers and rotating them over a display object on a mobile phone or tablet with a touch screen). Two-finger rotation is a common rotation gesture, but each device and operating system can have its own requirements to indicate rotation. Some devices might also interpret this contact as a combination of several mouse events, as well. Specifically, if a user moves a finger
over an InteractiveObject, the
InteractiveObject instance can dispatch a
When handling the properties of the event
object, note that the Note: See the Multitouch class for environment compatibility information. |
gestureSwipe | Dispatched when the user performs a swipe gesture at a point of contact with an InteractiveObject instance (such as touching three fingers to a screen and then moving them in parallel over a display object on a mobile phone or tablet with a touch screen). Moving several fingers in parallel is a common swipe gesture, but each device and operating system can have its own requirements for a swipe. Some devices might also interpret this contact as a combination of several mouse events, as well. Specifically, if a user moves a finger
over an InteractiveObject, and then moves the
fingers together, the InteractiveObject
instance can dispatch a When handling the properties of the event
object, note that the Note: While some devices using the Mac OS operating system can interpret a four-finger swipe, this API only supports a three-finger swipe. |
gestureTwoFingerTap | Dispatched when the user presses two points
of contact over the same InteractiveObject
instance on a touch-enabled device (such as
presses and releases two fingers over a
display object on a mobile phone or tablet
with a touch screen). Some devices might also
interpret this contact as a
Specifically, if a user taps two fingers
over an InteractiveObject, the
InteractiveObject instance can dispatch a
Note: See the Multitouch class for environment compatibility information. |
gestureZoom | Dispatched when the user performs a zoom gesture at a point of contact with an InteractiveObject instance (such as touching two fingers to a screen and then quickly spreading the fingers apart over a display object on a mobile phone or tablet with a touch screen). Moving fingers apart is a common zoom gesture, but each device and operating system can have its own requirements to indicate zoom. Some devices might also interpret this contact as a combination of several mouse events, as well. Specifically, if a user moves a finger
over an InteractiveObject, and then moves the
fingers apart, the InteractiveObject instance
can dispatch a When handling the properties of the event
object, note that the Note: See the Multitouch class for environment compatibility information. |
imeStartComposition | This event is dispatched to any client app that supports inline input with an IME |
keyDown | Dispatched when the user presses a key.
Mappings between keys and specific characters
vary by device and operating system. This
event type is generated after such a mapping
occurs but before the processing of an input
method editor (IME). IMEs are used to enter
characters, such as Chinese ideographs, that
the standard QWERTY keyboard is ill-equipped
to produce. This event occurs before the
In AIR, canceling this event prevents the character from being entered into a text field. |
keyFocusChange | Dispatched when the user attempts to change
focus by using keyboard navigation. The
default behavior of this event is to change
the focus and dispatch the corresponding
This event is dispatched to the object
that currently has focus. The related object
for this event is the InteractiveObject
instance that receives focus if you do not
prevent the default behavior. You can prevent
the change in focus by calling the
|
keyUp | Dispatched when the user releases a key.
Mappings between keys and specific characters
vary by device and operating system. This
event type is generated after such a mapping
occurs but before the processing of an input
method editor (IME). IMEs are used to enter
characters, such as Chinese ideographs, that
the standard QWERTY keyboard is ill-equipped
to produce. This event occurs after a
|
middleClick | Dispatched when a user presses and releases
the middle button of the user's pointing
device over the same InteractiveObject. For a
|
middleMouseDown | Dispatched when a user presses the middle pointing device button over an InteractiveObject instance. |
middleMouseUp | Dispatched when a user releases the pointing device button over an InteractiveObject instance. |
mouseDown | Dispatched when a user presses the pointing
device button over an InteractiveObject
instance. If the target is a SimpleButton
instance, the SimpleButton instance displays
the |
mouseFocusChange | Dispatched when the user attempts to change
focus by using a pointer device. The default
behavior of this event is to change the focus
and dispatch the corresponding
This event is dispatched to the object
that currently has focus. The related object
for this event is the InteractiveObject
instance that receives focus if you do not
prevent the default behavior. You can prevent
the change in focus by calling
|
mouseMove | Dispatched when a user moves the pointing device while it is over an InteractiveObject. If the target is a text field that the user is selecting, the selection is updated as the default behavior. |
mouseOut | Dispatched when the user moves a pointing
device away from an InteractiveObject
instance. The event target is the object
previously under the pointing device. The
The |
mouseOver | Dispatched when the user moves a pointing
device over an InteractiveObject instance.
The The |
mouseUp | Dispatched when a user releases the pointing
device button over an InteractiveObject
instance. If the target is a SimpleButton
instance, the object displays the
|
mouseWheel | Dispatched when a mouse wheel is spun over an InteractiveObject instance. If the target is a text field, the text scrolls as the default behavior. Only available on Microsoft Windows operating systems. |
nativeDragComplete | Dispatched by the drag initiator InteractiveObject when the user releases the drag gesture. The event's dropAction property indicates the action set by the drag target object; a value of "none"
that the drop was canceled or was not accepted. The |
nativeDragDrop | Dispatched by the target InteractiveObject when a dragged object is dropped on it and the drop has been accepted with a call to DragManager.acceptDragDrop(). Access the dropped data using the event
object The handler for this event should set the
|
nativeDragEnter | Dispatched by an InteractiveObject when a drag gesture enters its boundary. Handle either the
To determine whether the dispatching
display object can accept the drop, check the
suitability of the data in
|
nativeDragExit | Dispatched by an InteractiveObject when a drag gesture leaves its boundary. |
nativeDragOver | Dispatched by an InteractiveObject continually while a drag gesture remains within its boundary.
Handle either the
To determine whether the dispatching
display object can accept the drop, check the
suitability of the data in
|
nativeDragStart | Dispatched at the beginning of a drag operation by the InteractiveObject that is specified as the drag initiator in the DragManager.doDrag() call. |
nativeDragUpdate | Dispatched during a drag operation by the InteractiveObject that is specified as the drag initiator in the DragManager.doDrag() call.
|
paste | Dispatched when the user activates the platform-specific accelerator key combination for a paste operation or selects 'Paste' from the text context menu. This event is dispatched to the object that currently has focus. If the object that currently has focus is a TextField, the default behavior of this event is to cause the contents of the clipboard to be pasted into the text field at the current insertion point replacing any currently selected text in the text field. |
rightClick | Dispatched when a user presses and releases
the right button of the user's pointing
device over the same InteractiveObject. For a
|
rightMouseDown | Dispatched when a user presses the pointing device button over an InteractiveObject instance. |
rightMouseUp | Dispatched when a user releases the pointing device button over an InteractiveObject instance. |
rollOut | Dispatched when the user moves a pointing
device away from an InteractiveObject
instance. The event target is the object
previously under the pointing device or a
parent of that object. The
The purpose of the |
rollOver | Dispatched when the user moves a pointing
device over an InteractiveObject instance.
The event target is the object under the
pointing device or a parent of that object.
The The purpose of the |
selectAll | Dispatched when the user activates the platform-specific accelerator key combination for a select all operation or selects 'Select All' from the text context menu. This event is dispatched to the object that currently has focus. If the object that currently has focus is a TextField, the default behavior of this event is to cause all the contents of the text field to be selected. |
softKeyboardActivate | Dispatched immediately after the soft keyboard is raised. |
softKeyboardActivating | Dispatched immediately before the soft keyboard is raised. |
softKeyboardDeactivate | Dispatched immediately after the soft keyboard is lowered. |
tabChildrenChange | Dispatched when the value of the object's
|
tabEnabledChange | Dispatched when the object's
|
tabIndexChange | Dispatched when the value of the object's
|
textInput | Dispatched when a user enters one or more characters of text. Various text input methods can generate this event, including standard keyboards, input method editors (IMEs), voice or speech recognition systems, and even the act of pasting plain text with no formatting or style information. |
touchBegin | Dispatched when the user first contacts a
touch-enabled device (such as touches a
finger to a mobile phone or tablet with a
touch screen). Some devices might also
interpret this contact as a
Specifically, if a user touches a finger
to a touch screen, the InteractiveObject
instance can dispatch a
Note: See the Multitouch class for environment compatibility information. |
touchEnd | Dispatched when the user removes contact with
a touch-enabled device (such as lifts a
finger off a mobile phone or tablet with a
touch screen). Some devices might also
interpret this contact as a
Specifically, if a user lifts a finger
from a touch screen, the InteractiveObject
instance can dispatch a Note: See the Multitouch class for environment compatibility information. |
touchMove | Dispatched when the user moves the point of
contact with a touch-enabled device (such as
drags a finger across a mobile phone or
tablet with a touch screen). Some devices
might also interpret this contact as a
Specifically, if a user moves a finger
across a touch screen, the InteractiveObject
instance can dispatch a
Note: See the Multitouch class for environment compatibility information. |
touchOut | Dispatched when the user moves the point of
contact away from InteractiveObject instance
on a touch-enabled device (such as drags a
finger from one display object to another on
a mobile phone or tablet with a touch
screen). Some devices might also interpret
this contact as a Specifically, if a user moves a finger
across a touch screen, the InteractiveObject
instance can dispatch a Note: See the Multitouch class for environment compatibility information. |
touchOver | Dispatched when the user moves the point of
contact over an InteractiveObject instance on
a touch-enabled device (such as drags a
finger from a point outside a display object
to a point over a display object on a mobile
phone or tablet with a touch screen). Some
devices might also interpret this contact as
a Specifically, if a user moves a finger
over an InteractiveObject, the
InteractiveObject instance can dispatch a
Note: See the Multitouch class for environment compatibility information. |
touchRollOut | Dispatched when the user moves the point of
contact away from an InteractiveObject
instance on a touch-enabled device (such as
drags a finger from over a display object to
a point outside the display object on a
mobile phone or tablet with a touch screen).
Some devices might also interpret this
contact as a Specifically, if a user moves a finger
over an InteractiveObject, the
InteractiveObject instance can dispatch a
Note: See the Multitouch class for environment compatibility information. |
touchRollOver | Dispatched when the user moves the point of
contact over an InteractiveObject instance on
a touch-enabled device (such as drags a
finger from a point outside a display object
to a point over a display object on a mobile
phone or tablet with a touch screen). Some
devices might also interpret this contact as
a Specifically, if a user moves a finger
over an InteractiveObject, the
InteractiveObject instance can dispatch a
Note: See the Multitouch class for environment compatibility information. |
touchTap | Dispatched when the user lifts the point of
contact over the same InteractiveObject
instance on which the contact was initiated
on a touch-enabled device (such as presses
and releases a finger from a single point
over a display object on a mobile phone or
tablet with a touch screen). Some devices
might also interpret this contact as a
Specifically, if a user taps a finger over
an InteractiveObject, the InteractiveObject
instance can dispatch a Note: See the Multitouch class for environment compatibility information. |
See also:
Constructor
new()
Calling the new InteractiveObject()
constructor throws an
ArgumentError
exception. You can, however, call constructors
for the following subclasses of InteractiveObject:
new SimpleButton()
new TextField()
new Loader()
new Sprite()
new MovieClip()
Variables
doubleClickEnabled:Bool
Specifies whether the object receives doubleClick
events. The
default value is false
, which means that by default an
InteractiveObject instance does not receive doubleClick
events. If the doubleClickEnabled
property is set to
true
, the instance receives doubleClick
events
within its bounds. The mouseEnabled
property of the
InteractiveObject instance must also be set to true
for the
object to receive doubleClick
events.
No event is dispatched by setting this property. You must use the
addEventListener()
method to add an event listener for the
doubleClick
event.
focusRect:Null<Bool>
Specifies whether this object displays a focus rectangle. It can take
one of three values: true
, false
, or null
. Values of true
and
false
work as expected, specifying whether or not the focus
rectangle appears. A value of null
indicates that this object obeys
the stageFocusRect
property of the Stage.
mouseEnabled:Bool
Specifies whether this object receives mouse, or other user input,
messages. The default value is true
, which means that by
default any InteractiveObject instance that is on the display list
receives mouse events or other user input events. If
mouseEnabled
is set to false
, the instance does
not receive any mouse events (or other user input events like keyboard
events). Any children of this instance on the display list are not
affected. To change the mouseEnabled
behavior for all
children of an object on the display list, use
openfl.display.DisplayObjectContainer.mouseChildren
.
No event is dispatched by setting this property. You must use the
addEventListener()
method to create interactive
functionality.
needsSoftKeyboard:Bool
Specifies whether a virtual keyboard (an on-screen, software keyboard) should display when this InteractiveObject instance receives focus.
By default, the value is false
and focusing an
InteractiveObject instance does not raise a soft keyboard. If the
needsSoftKeyboard
property is set to true
, the
runtime raises a soft keyboard when the InteractiveObject instance is
ready to accept user input. An InteractiveObject instance is ready to
accept user input after a programmatic call to set the Stage
focus
property or a user interaction, such as a "tap." If the
client system has a hardware keyboard available or does not support
virtual keyboards, then the soft keyboard is not raised.
The InteractiveObject instance dispatches
softKeyboardActivating
, softKeyboardActivate
,
and softKeyboardDeactivate
events when the soft keyboard
raises and lowers.
Note: This property is not supported in AIR applications on iOS.
softKeyboardInputAreaOfInterest:Rectangle
Defines the area that should remain on-screen when a soft keyboard is
displayed.
If the needsSoftKeyboard
property of this InteractiveObject is
true
, then the runtime adjusts the display as needed to keep the
object in view while the user types. Ordinarily, the runtime uses the
object bounds obtained from the DisplayObject.getBounds()
method.
You can specify a different area using this
softKeyboardInputAreaOfInterest
property.
Specify the softKeyboardInputAreaOfInterest
in stage coordinates.
Note: On Android, the softKeyboardInputAreaOfInterest
is not
respected in landscape orientations.
tabEnabled:Bool
Specifies whether this object is in the tab order. If this object is
in the tab order, the value is true
; otherwise, the value is
false
. By default, the value is false
, except for the following:
For a SimpleButton object, the value is true
.
For a TextField object with type = "input"
, the value is true
.
* For a Sprite object or MovieClip object with buttonMode = true
,
the value is true
.
tabIndex:Int
Specifies the tab ordering of objects in a SWF file. The tabIndex
property is -1 by default, meaning no tab index is set for the object.
If any currently displayed object in the SWF file contains a
tabIndex
property, automatic tab ordering is disabled, and the tab
ordering is calculated from the tabIndex
properties of objects in
the SWF file. The custom tab ordering includes only objects that have
tabIndex
properties.
The tabIndex
property can be a non-negative integer. The objects are
ordered according to their tabIndex
properties, in ascending order.
An object with a tabIndex
value of 1 precedes an object with a
tabIndex
value of 2. Do not use the same tabIndex
value for
multiple objects.
The custom tab ordering that the tabIndex
property defines is
flat. This means that no attention is paid to the hierarchical
relationships of objects in the SWF file. All objects in the SWF file
with tabIndex
properties are placed in the tab order, and the tab
order is determined by the order of the tabIndex
values.
Note: To set the tab order for TLFTextField instances, cast the
display object child of the TLFTextField as an InteractiveObject, then
set the tabIndex
property. For example:
cast(tlfInstance.getChildAt(1), InteractiveObject).tabIndex = 3;
To reverse the tab order from the default setting for three instances of
a TLFTextField object (tlfInstance1
, tlfInstance2
and
tlfInstance3
), use:
cast(tlfInstance1.getChildAt(1), InteractiveObject).tabIndex = 3;
cast(tlfInstance2.getChildAt(1), InteractiveObject).tabIndex = 2;
cast(tlfInstance3.getChildAt(1), InteractiveObject).tabIndex = 1;
Methods
requestSoftKeyboard():Bool
Raises a virtual keyboard.
Calling this method focuses the InteractiveObject instance and raises
the soft keyboard, if necessary. The needsSoftKeyboard
must
also be true
. A keyboard is not raised if a hardware keyboard
is available, or if the client system does not support virtual
keyboards.
Note: This method is not supported in AIR applications on iOS.
Returns:
A value of true
means that the soft keyboard request
was granted; false
means that the soft keyboard was
not raised.