switchToMainWindow
Makes the app’s main window the active one until the returned DisposableEx is disposed.
See switchToWindow for why this is needed and what it changes, and getMainWindow for what counts as the main window.
Import:
import { switchToMainWindow } from 'obsidian-dev-utils/obsidian/workspace';Example:
// Raise a notice in the main window even while the settings window is open.using _mainWindowSwitch = switchToMainWindow(app);new Notice('This vault is a temporary sandbox.');Signature:
function switchToMainWindow(app: App): DisposableExParameters:
| Parameter | Type | Description |
|---|---|---|
app | App | The Obsidian app. |
Returns: DisposableEx — A DisposableEx that restores the previously active window when disposed.
Example:
// Raise a notice in the main window even while the settings window is open.using _mainWindowSwitch = switchToMainWindow(app);new Notice('This vault is a temporary sandbox.');