class NativeApplication
package openfl.desktop
extends EventDispatcher
Available on AIR, Android, HashLink, Linux, Neko, Windows, iOS, macOS
The NativeApplication class represents this OpenFL application.
The NativeApplication class provides application information, application-wide functions, and dispatches application-level events.
The NativeApplication object is a singleton object, created automatically
at startup. Get the NativeApplication instance of an application with the
static property NativeApplication.nativeApplication
.
Static variables
staticread onlynativeApplication:NativeApplication
The singleton instance of the NativeApplication
object.
staticread onlysupportsDefaultApplication:Bool
Indicates whether setAsDefaultApplication()
,
removeAsDefaultApplication()
, and isSetAsDefaultApplication()
are
supported on the current platform.
OpenFL target support: Not currently supported, except when targeting AIR.
If true
, then the above methods will work as documented. If false
,
then setAsDefaultApplication()
and removeDefaultApplication()
do
nothing and isSetAsDefaultApplication()
returns false
.
See also:
staticread onlysupportsDockIcon:Bool
Indicates whether OpenFL supports dock-style application icons on the current operating system.
OpenFL target support: Not currently supported, except when targeting AIR.
If true
, the NativeApplication.icon
property is of type DockIcon
.
The Mac OS X user interface provides an application "dock" containing icons for applications that are running or are frequently used.
Be sure to use the NativeApplication.supportsDockIcon
property to
determine whether the operating system supports application dock icons.
Using other means (such as Capabilities.os
) to determine support can
lead to programming errors (if some possible target operating systems
are not considered).
staticread onlysupportsMenu:Bool
Specifies whether the current operating system supports a global application menu bar.
OpenFL target support: Not currently supported, except when targeting AIR.
When true
, the NativeApplication.menu
property can be used to
define (or access) a native application menu.
Be sure to use the NativeApplication.supportsMenu
property to
determine whether the operating system supports the application menu
bar. Using other means (such as Capabilities.os
) to determine support
can lead to programming errors (if some possible target operating
systems are not considered).
staticread onlysupportsStartAtLogin:Bool
Indicates whether startAtLogin
is supported on the current platform.
OpenFL target support: Not currently supported, except when targeting AIR.
If true
, then startAtLogin
works as documented. If false
, then
startAtLogin
has no effect.
See also:
staticread onlysupportsSystemTrayIcon:Bool
Specifies whether OpenFL supports system tray icons on the current operating system.
OpenFL target support: Not currently supported, except when targeting AIR.
If true, the NativeApplication.icon
property is of type
SystemTrayIcon
.
The Windows user interface provides the "system tray" region of the task bar, officially called the Notification Area, in which application icons can be displayed. No default icon is shown. You must set the bitmaps array of the icon object to display an icon.
Be sure to use the NativeApplication.supportsSystemTrayIcon
property
to determine whether the operating system supports system tray icons.
Using other means (such as Capabilities.os
) to determine support can
lead to programming errors (if some possible target operating systems
are not considered).
Variables
read onlyactiveWindow:NativeWindow
The active application window.
If the active desktop window does not belong to this application, or
there is no active window, activeWindow
is null
.
This property is not supported on platforms that do not support the NativeWindow class.
read onlyapplicationID:String
The application ID of this application.
The value of this ID is set in the application descriptor file.
autoExit:Bool = true
Specifies whether the application should automatically terminate when all windows have been closed.
When autoExit
is true
, which is the default, the application
terminates when all windows are closed. Both exiting
and exit
events
are dispatched. When autoExit
is false
, you must call
NativeApplication.nativeApplication.exit()
to terminate the
application.
This property is not supported on platforms that do not support the
NativeWindow
class.
read onlyicon:InteractiveIcon = null
The application icon.
OpenFL target support: Not currently supported, except when targeting AIR.
Use NativeApplication.supportsDockIcon
and
NativeApplication.supportsSystemTrayIcon
to determine the icon class.
The type will be one of the subclasses of InteractiveIcon. On macOS,
NativeApplication.icon
is an object of type DockIcon. On Windows,
NativeApplication.icon
is an object of type SystemTrayIcon. When an
application icon is not supported, NativeApplication.supportsDockIcon
and NativeApplication.supportsSystemTrayIcon
are both false
and the
icon
property is null
.
The icon
object is automatically created, but it is not initialized
with image data. On some operating systems, such as macOS, a default
image is supplied. On others, such as Windows, the icon is not displayed
unless image data is assigned to it. To assign an icon image, set the
icon.bitmaps
property with an array containing at least one BitmapData
object. If more than one BitmapData object is included in the array,
then the operating system chooses the image that is closest in size to
the icon's display dimensions, scaling the image if necessary.
read onlyisCompiledAOT:Bool
In Adobe AIR, when targeting iOS, this property indicates if the
application was compiled AOT or if code is using the slower interpreter
without JIT. On all other platforms and operating systems, this
property returns false
.
read onlyopenedWindows:Array<NativeWindow>
An array containing all the open native windows of this application.
This property is not supported on platforms that do not support the NativeWindow class.
startAtLogin:Bool
Specifies whether this application is automatically launched whenever the current user logs in.
You can test for support at run time using the
NativeApplication.supportsStartAtLogin
property.
OpenFL target support: Not currently supported, except when targeting AIR.
Adobe AIR profile support: This feature is supported on all desktop operating systems, but is not supported on mobile devices or AIR for TV devices. See AIR Profile Support for more information regarding API support across multiple profiles.
The startAtLogin
property reflects the status of the
operating-system-defined mechanism for designating that an application
should start automatically when a user logs in. The user can change the
status manually by using the operating system user interface. This
property reflects the current status, whether the status was last
changed by the application or by the operating system.
See also:
Methods
exit(code:Int = 0):Void
Terminates this application.
The call to the exit()
method will return; the shutdown sequence does
not begin until the currently executing code (such as a current event
handler) has completed. Pending asynchronous operations are canceled and
may or may not complete.
Note that an exiting
event is not dispatched. If an exiting
event is
required by application logic, call
NativeApplication.nativeApplication.dispatchEvent()
, passing in an
Event
object of type exiting
. For any open windows, NativeWindow
objects do dispatch closing
and close
events. Calling the
preventDefault()
method of closing
event object prevents the
application from exiting.
Note: This method is not supported on the iOS operating system.
isSetAsDefaultApplication(extension:String):Bool
Specifies whether this application is currently the default application for opening files with the specified extension.
You can test for support at run time using the
NativeApplication.supportsDefaultApplication
property.
OpenFL target support: Not currently supported, except when targeting AIR.
Adobe AIR profile support: This feature is supported on all desktop operating systems, but is not supported on mobile devices or AIR for TV devices. See AIR Profile Support for more information regarding API support across multiple profiles.
removeAsDefaultApplication(extension:String):Void
Removes this application as the default for opening files with the specified extension.
OpenFL target support: Not currently supported, except when targeting AIR.
Note: This method can only be used with file types listed in the fileTypes statement in the application descriptor.
setAsDefaultApplication(extension:String):Void
Sets this application as the default application for opening files with the specified extension.
OpenFL target support: Not currently supported, except when targeting AIR.
Note: This method can only be used with file types declared in the fileTypes statement in the application descriptor.