Class: WindowClient

Window Client

The WindowClient is primarily responsible for managing the windowState (the window's bounds) and componentState (data inside of your component). It also injects the windowManager component, which contains controls for minimizing, maximizing, closing, and restoring your window. The reference below is provided in case you'd like to manually trigger events.

This is the WindowClient API reference. If you're looking for information about the window header, please see the windowManagerComponent for more information.

Members

optionsWindowClient

A copy of the finWindow's options value. This is where we store information like monitorDimensions, initialization information, and any other data that needs to be passed from the parent application into the created window.

Methods

centerMe
()

clients/windowClient.js, line 548

Centers window in the middle of the monitor that it is on.

Example
FSBL.Clients.WindowClient.centerMe();

close
(removeFromWorkspace)

clients/windowClient.js, line 299

Closes Window.

Name Type Description
removeFromWorkspace boolean

whether to remove the window from the workspace.
Defaults are to remove the window from the workspace if the user presses the X button, but not if the window is closed via an app-level request (e.g., we need to switch workspaces, so all windows need to close).

Example
//Close window and remove from workspace (e.g., user closes the window).
	FSBL.Clients.WindowClient.close(true);
	//Close window and keep in workspace (e.g., application requests that all windows close themselves).
	FSBL.Clients.WindowClient.close(false);

getComponentState
(params, cb)

clients/windowClient.js, line 374

Given a field, this function retrieves app state.

Name Type Description
params object
Name Type Description
field string

field

cb function

Callback

Example

The example below shows how we retrieve data to restore the layout in our charts.

FSBL.Clients.WindowClient.getComponentState({
	 field: 'myChartLayout',
}, function (err, state) {
	if (state === null) {
		return;
	}
	importLayout(state);
});

getWindowTitle
(){String}

clients/windowClient.js, line 83

Retrieves the window's title.

Returns:
Type Description
String title
Example
var windowTitle = FSBL.Clients.WindowClient.getWindowTitle();

maximize
()

clients/windowClient.js, line 268

Maximizes the window. Also takes into account the application toolbar.

Example
FSBL.Clients.WindowClient.maximize();

minimize
()

clients/windowClient.js, line 226

Minmizes window.

Example
FSBL.Clients.WindowClient.minimize();

restore
()

clients/windowClient.js, line 236

Restores window from a maximized state.

Example
FSBL.Clients.WindowClient.restore();

saveWindowState
(bounds)

clients/windowClient.js, line 158

Saves the window's state. Rarely called manually, as it's called every time your window moves.

Name Type Description
bounds Object

optional param.

Example

The code below is the bulk of our listener for the bounds-changed event from the openFin window. Every time the bounds-changed event is fired (when the window is resized or moved), we save the window's state. The first few lines just prevent the window from being dropped behind the toolbar.

finWindow.addEventListener('disabled-frame-bounds-changed', function (bounds) {
	if (bounds.top < 45) {
		finWindow.moveTo(bounds.left, 45);
		return;
	}
	self.saveWindowState(bounds);
});

setComponentState
(params, cb)

clients/windowClient.js, line 421

Given a field, this function sets and persists app state.

Name Type Description
params object
Name Type Description
field string

field

cb function optional

Callback

Example

The example below shows how we save our chart layout when it changes.

var s = stx.exportLayout(true);
//saving layout'
FSBL.Clients.WindowClient.setComponentState({ field: 'myChartLayout', value: s });

setWindowTitle
(title)

clients/windowClient.js, line 68

This function does two things:

  1. It sets the window's title in the windowManager component, and
  2. It sets the title in the DOM.

This is useful if you like to keep the window's title in sync with a piece of data (e.g., a Symbol);

TODO
  • Allow HTML or classes to be injected into the title.
Name Type Description
title String

Window title.

Example

The code shows how you would change your window title.

FSBL.Clients.WindowClient.setWindowTitle("My Component's New Title");