SnapAndDock

Layouts v1 API is deprecated and no longer supported as of OpenFin 16+. Please use Platform API instead.

Index

Type aliases

DockGroup

DockGroup: (WindowIdentity | WindowIdentity[])[]

Represents a group of docked entities (windows and/or tab groups)

An array entry of type WindowIdentity represents a single window

An array entry of type WindowIdentity[] represents a tab group. The elements of this sub-array are the identities of the tabs that form the tab group.

Events

WindowDockedEvent

WindowDockedEvent:

Event fired when one window is docked to another. See addEventListener.

It is not possible to receive events for another window. When adding a listener, the listener will only ever fire for the "fin.desktop.Window.getCurrent()" window.

import {addEventListener} from 'openfin-layouts';
import {WindowDockedEvent} from 'openfin-layouts/dist/client/snapanddock';

addEventListener('window-docked', async (event: WindowDockedEvent) => {
    console.log("Docked to another window");

    // Using 'v1' API
    fin.desktop.Window.getCurrent().getGroup((windows) => {
        console.log("Windows in current group: ", windows);
    });

    // Using 'v2' API
    console.log("Windows in current group: ", await fin.Window.getCurrentSync().getGroup());
});

This event is fired when the window first becomes docked. The window will not receive an event if an additional window is added to the group later.

type

type: "window-docked"

WindowUndockedEvent

WindowUndockedEvent:

Event fired when one window is undocked from it's neighbor(s). See addEventListener.

It is not possible to receive events for another window. When adding a listener, the listener will only ever fire for the "fin.desktop.Window.getCurrent()" window.

import {addEventListener} from 'openfin-layouts';
import {WindowUndockedEvent} from 'openfin-layouts/dist/client/snapanddock';

addEventListener('window-undocked', async (event: WindowUndockedEvent) => {
    console.log("Undocked from another window");

    // Using 'v1' API
    fin.desktop.Window.getCurrent().getGroup((windows) => {
        console.log("Windows in current group: ", windows);
    });

    // Using 'v2' API
    console.log("Windows in current group: ", await fin.Window.getCurrentSync().getGroup());
});

This event is fired when the current window becomes undocked from a group. A window will not receive this event if another window within the same group is undocked.

type

type: "window-undocked"

Functions

addEventListener

  • addEventListener(eventType: "window-docked", listener: function): void
  • addEventListener(eventType: "window-undocked", listener: function): void

getDockedWindows

  • getDockedWindows(identity?: Identity): Promise<DockGroup | null>
  • Returns an array representing the entities docked with the provided window (see DockGroup for more details).

    If the window is not docked returns null.

    import {snapAndDock} from 'openfin-layouts';
    
    // Gets all tabs for the current window context.
    const myGroup: DockGroup | null = snapAndDock.getDockedWindows();
    
    // Get all tabs for another window context.
    const otherWindow: Identity = {uuid: "sample-window-uuid", name: "sample-window-name"}
    const otherWindowGroup: DockGroup | null = snapAndDock.getDockedWindows(otherWindow);
    throws

    Error: If identity is not a valid Identity.

    throws

    Error: If the window specified by identity does not exist

    throws

    Error: If the window specified by identity has been de-registered

    throws

    Error: If the provider is running an incompatible version

    since

    1.0.3

    Parameters

    • Default value identity: Identity = getId()

      The window context, defaults to the current window.

    Returns Promise<DockGroup | null>

removeEventListener

  • removeEventListener(eventType: "window-docked", listener: function): void
  • removeEventListener(eventType: "window-undocked", listener: function): void

undockGroup

  • undockGroup(identity?: Identity): Promise<void>
  • Will undock every window that is currently connected to a current window.

    This will completely disband the entire group, not just the windows directly touching identity.

    Has no effect if identity isn't currently snapped to any other window.

    import {snapAndDock} from 'openfin-layouts';
    
    // Undock all windows attached to the current window (all are equivalent)
    snapAndDock.undockGroup();
    snapAndDock.undockGroup(fin.desktop.Window.getCurrent());   // Using 'v1' API
    snapAndDock.undockGroup(fin.Window.getCurrentSync());       // Using 'v2' API
    
    // Undock all windows attached to a different window
    snapAndDock.undockGroup({uuid: 'my-app', name: 'other-window'});
    throws

    Error: If identity is not a valid Identity.

    throws

    Error: If the window specified by identity does not exist

    throws

    Error: If the window specified by identity has been de-registered

    Parameters

    • Default value identity: Identity = getId()

      A window belonging to the group that should be disbanded, defaults to the current window/group

    Returns Promise<void>

undockWindow

  • undockWindow(identity?: Identity): Promise<void>
  • Undocks a window from any group it currently belongs to.

    Has no effect if the window is not currently docked.

    import {snapAndDock} from 'openfin-layouts';
    
    // Undock the current window (all are equivalent)
    snapAndDock.undockWindow();
    snapAndDock.undockWindow(fin.desktop.Window.getCurrent());   // Using 'v1' API
    snapAndDock.undockWindow(fin.Window.getCurrentSync());       // Using 'v2' API
    
    // Undock a different window
    snapAndDock.undockWindow({uuid: 'my-app', name: 'other-window'});
    throws

    Error: If identity is not a valid Identity.

    throws

    Error: If the window specified by identity does not exist

    throws

    Error: If the window specified by identity has been de-registered

    Parameters

    • Default value identity: Identity = getId()

      The window to undock, defaults to the current window

    Returns Promise<void>