Provides access to the OpenFin representation of the current code context (usually a document
such as a View or Window), as well as to the current Interop
context.
Useful for debugging in the devtools console, where this will intelligently type itself based on the context in which the devtools panel was opened.
Synchronously returns a Layout object that represents a Window's layout.
Cannot be called from a view.
const layout = fin.Platform.Layout.getCurrentSync();
// Use wrapped instance to control layout, e.g.:
const layoutConfig = await layout.getConfig();
Experimental
Initialize the window's Layout.
Layout init options.
Must be called from a custom window that has a 'layout' option set upon creation of that window.
If a containerId is not provided, this method attempts to find an element with the id layout-container
.
A Layout will emit events locally on the DOM element representing the layout-container.
In order to capture the relevant events during Layout initiation, set up the listeners on the DOM element prior to calling init
.
// If no options are included, the layout in the window options is initialized in an element with the id `layout-container`
const layout = await fin.Platform.Layout.init();
const containerId = 'my-custom-container-id';
const myLayoutContainer = document.getElementById(containerId);
myLayoutContainer.addEventListener('tab-created', function(event) {
const { tabSelector } = event.detail;
const tabElement = document.getElementById(tabSelector);
const existingColor = tabElement.style.backgroundColor;
tabElement.style.backgroundColor = "red";
setTimeout(() => {
tabElement.style.backgroundColor = existingColor;
}, 2000);
});
// initialize the layout into an existing HTML element with the div `my-custom-container-id`
// the window must have been created with a layout in its window options
const layout = await fin.Platform.Layout.init({ containerId });
Asynchronously returns a Layout object that represents a Window's layout.
let windowIdentity;
if (!fin.me.isWindow) {
windowIdentity = fin.me.identity;
} else if (fin.me.isView) {
windowIdentity = (await fin.me.getCurrentWindow()).identity;
} else {
throw new Error('Not running in a platform View or Window');
}
const layout = await fin.Platform.Layout.wrap(windowIdentity);
// Use wrapped instance to control layout, e.g.:
const layoutConfig = await layout.getConfig();
Synchronously returns a Layout object that represents a Window's layout.
let windowIdentity;
if (!fin.me.isWindow) {
windowIdentity = fin.me.identity;
} else if (fin.me.isView) {
windowIdentity = (await fin.me.getCurrentWindow()).identity;
} else {
throw new Error('Not running in a platform View or Window');
}
const layout = fin.Platform.Layout.wrapSync(windowIdentity);
// Use wrapped instance to control layout, e.g.:
const layoutConfig = await layout.getConfig();
Static namespace for OpenFin API methods that interact with the Layout class, available under
fin.Platform.Layout
.