1. Windows
  2. Creating Multiple Windows

Windows

Creating Multiple Windows

ToDesktop supports the creation of multiple desktop windows. Some of the more popular window combinations are:

  • A main application window, with a secondary menubar window for displaying summary information.
  • A main application window, with a secondary keyboard-accessible panel window for quickly entering data.

Adding secondary windows is as simple as navigating to the Windows view and clicking the + icon. From there, you can tweak different window settings:

User interface with a highlighted red box that shows how to add a new window.

New windows can also be created via the API using @todesktop/client-core. To begin, install @todesktop/client-core in the relevant project:

        npm install @todesktop/client-core

      

Creating a window is a two-step process that involves creating the window and then loading the URL into it's contents.

        import { nativeWindow, webContents } from '@todesktop/client-core';

async function main() {
  const windowRef = await nativeWindow.create({});

  await webContents.loadURL(
    { ref: await nativeWindow.getWebContents({ ref: windowRef }) },
    'http://localhost:3000'
  );
}

main();

      

For a more complex example, visit our tutorial that creates a multi-window todo application.