Constructor
new Window(options, callbackopt, errorCallbackopt)
Creates a new Window.
Best practice is to invoke with the new
operand.
See the window.constructor tutorial for an example.
Failure to use the new
operand will result in a console warning (but will otherwise succeed).
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
options |
fin.desktop.Window~options | Window creation options. See options for more details. |
|
callback |
successCallback |
<optional> |
Called if the method succeeds. See success callback for shape. |
errorCallback |
errorCallback |
<optional> |
Called if there is a network error. See error callback for shape. |
- Tutorials:
Methods
(static) getCurrent() → {fin.desktop.Window}
Returns an instance of the current window.
- Tutorials:
Returns:
- Type
- fin.desktop.Window
(static) wrap(appUuid, windowName) → {fin.desktop.Window}
Returns a Window object that wraps an existing window.
Parameters:
Name | Type | Description |
---|---|---|
appUuid |
string | The UUID of the application to which the window to be wrapped belongs. |
windowName |
string | The name of the window to be wrapped. |
- Tutorials:
Returns:
- Type
- fin.desktop.Window
addEventListener(type, listener, callbackopt, errorCallbackopt)
Registers an event listener on the specified event.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
type |
string | The type of the event. |
|
listener |
function | Called whenever an event of the specified type occurs. It is passed an event object containing information related to the event. |
|
callback |
function |
<optional> |
called if the method succeeds. |
errorCallback |
function |
<optional> |
called if the method fails. The reason for failure is passed as an argument. |
- Tutorials:
animate(transitions, options, callbackopt, errorCallbackopt)
Performs the specified window transitions.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
transitions |
object | Describes the animations to preform. See the tutorial. |
|
options |
object | Options for the animation. See the tutorial. |
|
callback |
function |
<optional> |
called if the method succeeds. |
errorCallback |
function |
<optional> |
called if the method fails. The reason for failure is passed as an argument. |
- Tutorials:
authenticate(userName, password, callbackopt, errorCallbackopt)
Provides credentials to authentication requests
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
userName |
string | userName to provide to the authentication challange |
|
password |
string | password to provide to the authentication challange |
|
callback |
function |
<optional> |
called if the method succeeds. |
errorCallback |
function |
<optional> |
called if the method fails. The reason for failure is passed as an argument. |
- Tutorials:
blur(callbackopt, errorCallbackopt)
Removes focus from the window.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
callback |
function |
<optional> |
called if the method succeeds. |
errorCallback |
function |
<optional> |
called if the method fails. The reason for failure is passed as an argument. |
- Tutorials:
bringToFront(callbackopt, errorCallbackopt)
Brings the window to the front of the window stack.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
callback |
function |
<optional> |
called if the method succeeds. |
errorCallback |
function |
<optional> |
called if the method fails. The reason for failure is passed as an argument. |
- Tutorials:
close(forceopt, callbackopt, errorCallbackopt)
Closes the window.
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
force |
boolean |
<optional> |
false | Close will be prevented from closing when force is false and ‘close-requested’ has been subscribed to for application’s main window. |
callback |
function |
<optional> |
called if the method succeeds. |
|
errorCallback |
function |
<optional> |
called if the method fails. The reason for failure is passed as an argument. |
- Tutorials:
disableFrame(callbackopt, errorCallbackopt)
Prevents a user from changing a window's size/position when using the window's frame.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
callback |
function |
<optional> |
called if the method succeeds. |
errorCallback |
function |
<optional> |
called if the method fails. The reason for failure is passed as an argument. |
- Tutorials:
enableFrame(callbackopt, errorCallbackopt)
Re-enables user changes to a window's size/position when using the window's frame.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
callback |
function |
<optional> |
called if the method succeeds. |
errorCallback |
function |
<optional> |
called if the method fails. The reason for failure is passed as an argument. |
- Tutorials:
executeJavaScript(code, callbackopt, errorCallbackopt)
Executes Javascript on the window, restricted to windows you own or windows owned by applications you have created.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
code |
string | JavaScript code to be executed on the window. |
|
callback |
function |
<optional> |
called if the method succeeds. |
errorCallback |
function |
<optional> |
called if the method fails. The reason for failure is passed as an argument. |
- Tutorials:
flash(callbackopt, errorCallbackopt)
Flashes the window’s frame and taskbar icon until stopFlashing is called.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
callback |
function |
<optional> |
called if the method succeeds. |
errorCallback |
function |
<optional> |
called if the method fails. The reason for failure is passed as an argument. |
- Tutorials:
focus(callbackopt, errorCallbackopt)
Gives focus to the window.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
callback |
function |
<optional> |
called if the method succeeds. |
errorCallback |
function |
<optional> |
called if the method fails. The reason for failure is passed as an argument. |
- Tutorials:
getAllFrames(callbackopt, errorCallbackopt)
Retrieves an array of frame info objects representing the main frame and any iframes that are currently on the page.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
callback |
function |
<optional> |
called if the method succeeds. |
errorCallback |
function |
<optional> |
called if the method fails. The reason for failure is passed as an argument. |
- Tutorials:
getBounds(callbackopt, errorCallbackopt)
Gets the current bounds (top, left, width, height) of the window.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
callback |
function |
<optional> |
called if the method succeeds. |
errorCallback |
function |
<optional> |
called if the method fails. The reason for failure is passed as an argument. |
- Tutorials:
getInfo(callbackopt, errorCallbackopt) → {fin.desktop.Application#windowInfo}
Gets an information object for the window.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
callback |
function |
<optional> |
called if the method succeeds. A windowInfo object is passed as an argument. |
errorCallback |
function |
<optional> |
called if the method fails. The reason for failure is passed as an argument. |
- Tutorials:
Returns:
- Type
- fin.desktop.Application#windowInfo
getNativeWindow() → {window}
Returns the native JavaScript "window" object for the window.
- Tutorials:
Returns:
- Type
- window
getOptions(callbackopt, errorCallbackopt)
Gets the current settings of the window.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
callback |
function |
<optional> |
called if the method succeeds. |
errorCallback |
function |
<optional> |
called if the method fails. The reason for failure is passed as an argument. |
- Tutorials:
getParentApplication() → {fin.desktop.Application}
Gets the parent application.
- Tutorials:
Returns:
getParentWindow() → {fin.desktop.Window}
Gets the parent window.
- Tutorials:
Returns:
- Type
- fin.desktop.Window
getSnapshot(areaopt, callbackopt, errorCallbackopt)
Gets a base64 encoded PNG snapshot of the window or just a part of it.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
area |
rect |
<optional> |
The area of the page to be captured. Omitting it will capture the whole visible page. |
callback |
function |
<optional> |
called if the method succeeds. |
errorCallback |
function |
<optional> |
called if the method fails. The reason for failure is passed as an argument. |
- Tutorials:
getState(callbackopt, errorCallbackopt)
Gets the current state ("minimized", "maximized", or "restored") of the window.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
callback |
function |
<optional> |
called if the method succeeds. |
errorCallback |
function |
<optional> |
called if the method fails. The reason for failure is passed as an argument. |
- Tutorials:
getZoomLevel(callbackopt, errorCallbackopt)
Returns the zoom level of the window.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
callback |
function |
<optional> |
called if the method succeeds. |
errorCallback |
function |
<optional> |
called if the method fails. The reason for failure is passed as an argument. |
- Tutorials:
hide(callbackopt, errorCallbackopt)
Hides the window.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
callback |
function |
<optional> |
called if the method succeeds. |
errorCallback |
function |
<optional> |
called if the method fails. The reason for failure is passed as an argument. |
- Tutorials:
isShowing(callbackopt, errorCallbackopt)
Determines if the window is currently showing. For current state of the window, use getState().
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
callback |
function |
<optional> |
called if the method succeeds. |
errorCallback |
function |
<optional> |
called if the method fails. The reason for failure is passed as an argument. |
- Tutorials:
maximize(callbackopt, errorCallbackopt)
Maximizes the window.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
callback |
function |
<optional> |
called if the method succeeds. |
errorCallback |
function |
<optional> |
called if the method fails. The reason for failure is passed as an argument. |
- Tutorials:
minimize(callbackopt, errorCallbackopt)
Minimizes the window.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
callback |
function |
<optional> |
called if the method succeeds. |
errorCallback |
function |
<optional> |
called if the method fails. The reason for failure is passed as an argument. |
- Tutorials:
moveBy(deltaLeft, deltaTop, callbackopt, errorCallbackopt)
Moves the window by a specified amount.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
deltaLeft |
int | The change in the left position of the window. |
|
deltaTop |
int | The change in the top position of the window. |
|
callback |
function |
<optional> |
called if the method succeeds. |
errorCallback |
function |
<optional> |
called if the method fails. The reason for failure is passed as an argument. |
- Tutorials:
moveTo(left, top, callbackopt, errorCallbackopt)
Moves the window to a specified location.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
left |
int | The left position of the window. |
|
top |
int | The top position of the window. |
|
callback |
function |
<optional> |
called if the method succeeds. |
errorCallback |
function |
<optional> |
called if the method fails. The reason for failure is passed as an argument. |
- Tutorials:
navigate(url, callbackopt, errorCallbackopt)
Navigates the window to a specified URL. The url must contain the protocol prefix such as http:// or https://.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
url |
string | The URL to navigate the window to. |
|
callback |
function |
<optional> |
called if the method succeeds. |
errorCallback |
function |
<optional> |
called if the method fails. The reason for failure is passed as an argument. |
- Tutorials:
navigateBack(callbackopt, errorCallbackopt)
Navigates the window back one page.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
callback |
function |
<optional> |
called if the method succeeds. |
errorCallback |
function |
<optional> |
called if the method fails. The reason for failure is passed as an argument. |
- Tutorials:
navigateForward(callbackopt, errorCallbackopt)
Navigates the window forward one page.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
callback |
function |
<optional> |
called if the method succeeds. |
errorCallback |
function |
<optional> |
called if the method fails. The reason for failure is passed as an argument. |
- Tutorials:
reload(ignoreCacheopt, callbackopt, errorCallbackopt)
Reloads the window current page.
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
ignoreCache |
boolean |
<optional> |
false | Specifies if the cache should be ignored during page reload. |
callback |
function |
<optional> |
called if the method succeeds. |
|
errorCallback |
function |
<optional> |
called if the method fails. The reason for failure is passed as an argument. |
- Tutorials:
removeEventListener(type, listener, callbackopt, errorCallbackopt)
Removes a previously registered event listener from the specified event.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
type |
string | The type of the event |
|
listener |
function | Called whenever an event of the specified type occurs. It is passed an event object containing information related to the event. |
|
callback |
function |
<optional> |
called if the method succeeds. |
errorCallback |
function |
<optional> |
called if the method fails. The reason for failure is passed as an argument. |
- Tutorials:
resizeBy(deltaWidth, deltaHeight, anchor, callbackopt, errorCallbackopt)
Resizes the window by a specified amount.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
deltaWidth |
int | The change in the width of the window. |
|
deltaHeight |
int | The change in the height of the window. |
|
anchor |
string | Specifies a corner to remain fixed during the resize. Can take the values: "top-left", "top-right", "bottom-left", or "bottom-right." If undefined, the default is "top-left". |
|
callback |
function |
<optional> |
called if the method succeeds. |
errorCallback |
function |
<optional> |
called if the method fails. The reason for failure is passed as an argument. |
- Tutorials:
resizeTo(width, height, anchor, callbackopt, errorCallbackopt)
Resizes the window to the specified dimensions.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
width |
int | The change in the width of the window. |
|
height |
int | The change in the height of the window. |
|
anchor |
string | Specifies a corner to remain fixed during the resize. Can take the values: "top-left", "top-right", "bottom-left", or "bottom-right." If undefined, the default is "top-left". |
|
callback |
function |
<optional> |
called if the method succeeds. |
errorCallback |
function |
<optional> |
called if the method fails. The reason for failure is passed as an argument. |
- Tutorials:
restore(callbackopt, errorCallbackopt)
Restores the window to its normal state (i.e., unminimized, unmaximized).
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
callback |
function |
<optional> |
called if the method succeeds. |
errorCallback |
function |
<optional> |
called if the method fails. The reason for failure is passed as an argument. |
- Tutorials:
setAsForeground(callbackopt, errorCallbackopt)
Will bring the window to the front of the entire stack and give it focus.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
callback |
function |
<optional> |
called if the method succeeds. |
errorCallback |
function |
<optional> |
called if the method fails. The reason for failure is passed as an argument. |
- Tutorials:
setBounds(left, top, width, height, callbackopt, errorCallbackopt)
Sets the window's size and position.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
left |
int | The left position of the window. |
|
top |
int | The top position of the window. |
|
width |
int | The width of the window. |
|
height |
int | The height of the window. |
|
callback |
function |
<optional> |
called if the method succeeds. |
errorCallback |
function |
<optional> |
called if the method fails. The reason for failure is passed as an argument. |
- Tutorials:
setZoomLevel(level, callbackopt, errorCallbackopt)
Sets the zoom level of the window.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
level |
Number | The zoom level. |
|
callback |
function |
<optional> |
called if the method succeeds. |
errorCallback |
function |
<optional> |
called if the method fails. The reason for failure is passed as an argument. |
- Tutorials:
show(forceopt, callbackopt, errorCallbackopt)
Shows the window if it is hidden.
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
force |
boolean |
<optional> |
false | Show will be prevented from closing when force is false and ‘show-requested’ has been subscribed to for application’s main window. |
callback |
function |
<optional> |
called if the method succeeds. |
|
errorCallback |
function |
<optional> |
called if the method fails. The reason for failure is passed as an argument. |
- Tutorials:
showAt(left, top, forceopt, callbackopt, errorCallbackopt)
Shows the window if it is hidden at the specified location. If the toggle parameter is set to true, the window will alternate between showing and hiding.
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
left |
int | The left position of the window. |
||
top |
int | The right position of the window. |
||
force |
boolean |
<optional> |
false | Show will be prevented from closing when force is false and ‘show-requested’ has been subscribed to for application’s main window. |
callback |
function |
<optional> |
called if the method succeeds. |
|
errorCallback |
function |
<optional> |
called if the method fails. The reason for failure is passed as an argument. |
- Tutorials:
stopFlashing(callbackopt, errorCallbackopt)
Stops the taskbar icon from flashing.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
callback |
function |
<optional> |
called if the method succeeds. |
errorCallback |
function |
<optional> |
called if the method fails. The reason for failure is passed as an argument. |
- Tutorials:
stopNavigation(callbackopt, errorCallbackopt)
Stops any current navigation the window is performing.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
callback |
function |
<optional> |
called if the method succeeds. |
errorCallback |
function |
<optional> |
called if the method fails. The reason for failure is passed as an argument. |
- Tutorials:
updateOptions(options, callbackopt, errorCallbackopt)
Updates the window using the passed options. Values that are objects are deep-merged, overwriting only the values that are provided.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
options |
object | Changes a window's options that were defined upon creation. See tutorial. |
|
callback |
function |
<optional> |
called if the method succeeds. |
errorCallback |
function |
<optional> |
called if the method fails. The reason for failure is passed as an argument. |
- Tutorials:
Type Definitions
windowInfo
Object returned by fin.desktop.Window#getInfo.
Type:
- object
Properties:
Name | Type | Description |
---|---|---|
url |
string | Uniform Resource Locator of the currently loaded page. |
title |
string | Page title appearing in title bar of window. This will be the markup defined in the |
options
Window creation options.
This is the options object required by the Window
constructor.
Note that name
is the only required property — albeit the url
property is usually provided as well (defaults to "about:blank"
when omitted).
This jsdoc typedef mirrors the WindowOptions
TypeScript interface in @types/openfin
.
Type:
- object
Properties:
Name | Type | Attributes | Default | Description | |||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
accelerator |
object |
<optional> |
Enable keyboard shortcuts for devtools, zoom, reload, and reload ignoring cache. Properties
|
||||||||||||||||||||||||||
alwaysOnTop |
boolean |
<optional> |
false | Updatable. A flag to always position the window at the top of the window stack. |
|||||||||||||||||||||||||
api |
object |
<optional> |
Configurations for API injection. Properties
|
||||||||||||||||||||||||||
aspectRatio |
number |
<optional> |
0 | Updatable. The aspect ratio of width to height to enforce for the window. If this value is equal to or less than zero, an aspect ratio will not be enforced. |
|||||||||||||||||||||||||
autoShow |
boolean |
<optional> |
false | A flag to automatically show the window when it is created. |
|||||||||||||||||||||||||
backgroundColor |
string |
<optional> |
"#FFF" | The window’s backfill color as a hexadecimal value. Not to be confused with the content background color ( |
|||||||||||||||||||||||||
contentNavigation |
object |
<optional> |
Restrict navigation to URLs that match a whitelisted pattern. See here for more details. Properties
|
||||||||||||||||||||||||||
contextMenu |
boolean |
<optional> |
true | Updatable. A flag to show the context menu when right-clicking on a window. Gives access to the devtools for the window. |
|||||||||||||||||||||||||
cornerRounding |
object |
<optional> |
Updatable. Defines and applies rounded corners for a frameless window. NOTE: On macOS corner is not ellipse but circle rounded by the average of height and width. Properties
|
||||||||||||||||||||||||||
customData |
string |
<optional> |
"" | Updatable.
A field that the user can attach serializable data to to be ferried around with the window options.
When omitted, the default value of this property is the empty string ( |
|||||||||||||||||||||||||
customRequestHeaders |
Array.<customRequestHeaders> |
<optional> |
Defines list of customRequestHeaders for requests sent by the window. |
||||||||||||||||||||||||||
defaultCentered |
boolean |
<optional> |
false | Centers the window in the primary monitor. This option overrides |
|||||||||||||||||||||||||
defaultHeight |
number |
<optional> |
500 | The default height of the window. When |
|||||||||||||||||||||||||
defaultLeft |
number |
<optional> |
100 | The default left position of the window. When |
|||||||||||||||||||||||||
defaultTop |
number |
<optional> |
100 | The default top position of the window. When |
|||||||||||||||||||||||||
defaultWidth |
number |
<optional> |
800 | The default width of the window. When |
|||||||||||||||||||||||||
frame |
boolean |
<optional> |
true | Updatable. A flag to show the frame. |
|||||||||||||||||||||||||
icon |
string |
<optional> |
Updatable. Inheritable. A URL for the icon to be shown in the window title bar and the taskbar. When omitted, inherits from the parent application. |
||||||||||||||||||||||||||
maxHeight |
number |
<optional> |
-1 | Updatable. The maximum height of a window. Will default to the OS defined value if set to -1. |
|||||||||||||||||||||||||
maximizable |
boolean |
<optional> |
true | Updatable. A flag that lets the window be maximized. |
|||||||||||||||||||||||||
maxWidth |
number |
<optional> |
-1 | Updatable. The maximum width of a window. Will default to the OS defined value if set to -1. |
|||||||||||||||||||||||||
minHeight |
number |
<optional> |
0 | Updatable. The minimum height of a window. |
|||||||||||||||||||||||||
minimizable |
boolean |
<optional> |
true | Updatable. A flag that lets the window be minimized. |
|||||||||||||||||||||||||
minWidth |
number |
<optional> |
0 | Updatable. The minimum width of a window. |
|||||||||||||||||||||||||
name |
string | The name of the window. |
|||||||||||||||||||||||||||
opacity |
number |
<optional> |
1.0 | Updatable.
A flag that specifies how transparent the window will be.
This value is clamped between |
|||||||||||||||||||||||||
preloadScripts |
Array.<preloadScript> |
<optional> |
Inheritable A list of scripts that are eval'ed before other scripts in the page. When omitted, inherits from the parent application. |
||||||||||||||||||||||||||
resizable |
boolean |
<optional> |
true | Updatable. A flag to allow the user to resize the window. |
|||||||||||||||||||||||||
resizeRegion |
object |
<optional> |
Updatable. Defines a region in pixels that will respond to user mouse interaction for resizing a frameless window. Properties
|
||||||||||||||||||||||||||
saveWindowState |
boolean |
<optional> |
true | A flag to cache the location of the window. |
|||||||||||||||||||||||||
shadow |
boolean |
<optional> |
false | A flag to display a shadow on frameless windows.
|
|||||||||||||||||||||||||
showTaskbarIcon |
boolean |
<optional> |
true | Updatable. Windows. A flag to show the window's icon in the taskbar. |
|||||||||||||||||||||||||
smallWindow |
boolean |
<optional> |
false | A flag to specify a frameless window that can be be created and resized to less than 41x36px (width x height). Note: Caveats of small windows are no Aero Snap and drag to/from maximize. |
|||||||||||||||||||||||||
state |
string |
<optional> |
"normal" | The visible state of the window on creation. One of:
|
|||||||||||||||||||||||||
taskbarIconGroup |
string |
<optional> |
<application uuid> | Windows.
Specify a taskbar group for the window.
If omitted, defaults to app's uuid ( |
|||||||||||||||||||||||||
url |
string |
<optional> |
"about:blank" | The URL of the window. |
|||||||||||||||||||||||||
uuid |
string |
<optional> |
<application uuid> | The |
|||||||||||||||||||||||||
waitForPageLoad |
boolean |
<optional> |
true | By default (when set to |