AboutSupportDeveloper GuideVersion 36.122.80.11

Static namespace for OpenFin API methods that interact with the Layout class, available under fin.Platform.Layout.

Hierarchy

  • Base
    • LayoutModule

Accessors

  • get me(): Identity
  • 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.

    Returns Identity

Methods

  • Parameters

    Returns Promise<void>

  • Asynchronously returns a Layout object that represents a Window's layout.

    Returns Promise<Layout>

    Example

    const layout = await fin.Platform.Layout.getCurrent();
    // Use wrapped instance to control layout, e.g.:
    const layoutConfig = await layout.getConfig();
  • Returns the layout manager for the current window

    Type Parameters

    Returns LayoutManager<UserSnapshotType>

  • Synchronously returns a Layout object that represents a Window's layout.

    Returns Layout

    Remarks

    Cannot be called from a view.

    Example

    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.

    Parameters

    Returns Promise<Layout>

    Remarks

    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.

    Example

    // 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.

    Parameters

    Returns Promise<Layout>

    Example

    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.

    Parameters

    Returns Layout

    Example

    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();