new·The score now tells you which way it movedA brain's exam only ever grows: its own material writes questions, and so does every question a real caller asked and did not get answered. The score is a percentage over that growing set, so a brain that learned more could post a smaller number — and this week three did. One of them answered two MORE questions than the week before and showed eighteen points less. Printed as a single percentage, that reads as decline to a reader and as punishment to anyone who contributes material.all news →
mozg.beta
Sign in

Tauri · Develop · all subjects

state & window management

70 notes in this subject, read out of this brain and free to use. This is page 1 of 2.

Unfocused windows creation in Tauri 1.2.0

Tauri 1.2.0 reimplemented the option to create unfocused windows.

acceptFirstMouse window option on macOS in 1.2.0

Tauri 1.2.0 adds the acceptFirstMouse window option for macOS, allowing windows to be focused immediately after receiving a click event and to be dragged.

tabbingIdentifier window option on macOS in 1.2.0

Tauri 1.2.0 adds the tabbingIdentifier window option for macOS.

Enhanced macOS titlebar configuration in 1.2.0

Tauri 1.2.0 adds macOS titlebar style configuration allowing applications to define a transparent or overlay titlebar, hide the window title text, and set acceptFirstMouse to enable the window to be focused and dragged immediately after a click event.

User agent configuration when creating windows in 1.2.0

Tauri 1.2.0 allows configuring the user agent when creating a window.

SystemTray runtime creation example

Example showing how to create a system tray at runtime: use tauri::{Builder, CustomMenuItem, SystemTray, SystemTrayEvent, SystemTrayMenu}; Builder::default() .setup(|app| { let handle = app.handle(); SystemTray::new() .with_id("main") .with_menu( SystemTrayMenu::new().add_item(CustomMenuItem::new("quit", "Quit")) ) .on_event(move |event| { let tray_handle = handle.tray_handle_by_id("main").unwrap(); if let SystemTrayEvent::MenuItemClick { id, .. } = event { if id == "quit" { tray_handle.destroy().unwrap(); } } }) .build(&handle) .expect("unable to create tray"); });

Theme APIs on Linux

Tauri 1.1.0 adds Theme APIs on Linux.

RefCell window storage improvement

Tauri 1.1.0 keeps created windows in a RefCell instead of a Mutex, avoiding deadlocks.

SystemTray runtime creation API

Tauri 1.1.0 adds the ability to create system trays at runtime using tauri::SystemTray, in addition to the existing tauri::Builder::system_tray API. This allows control over tray lifetime and creation of multiple trays.

Window control disable API methods

The Rust APIs set_maximizable, set_minimizable, and set_closable allow disabling window controls programmatically. The JavaScript equivalents are setMaximizable, setMinimizable, and setClosable.

Webview theme synchronization in Tauri 1.3 on Windows

Tauri 1.3 changes the webview theme based on the Window theme on Windows for more accurate prefers-color-scheme support.

Window methods added in Tauri 1.3

Tauri 1.3 adds several new window methods: is_minimized() to check if a window is minimized, a title getter to retrieve the window title, url() getter to retrieve the window's URL, and on_navigation() to handle window navigation events.

Content protection APIs added in Tauri 1.3

Tauri 1.3 introduces content protection APIs for protecting window content from screen capture and recording.

Device event filtering in Tauri 1.3

Tauri 1.3 adds Builder::device_event_filter and App::set_device_event_filter methods to control which device events are processed by the application.

System tray tooltip support for Windows and macOS in Tauri 1.3

Tauri 1.3 implements SystemTray::with_tooltip and SystemTrayHandle::set_tooltip methods for Windows and macOS to display tooltips on system tray icons.

Dialog button text customization in Tauri 1.3

Tauri 1.3 allows setting custom text for dialog buttons through the dialog API.

WindowBuilder recreate from tauri.conf.json in Tauri 1.3

Tauri 1.3 adds a method to the WindowBuilder struct to recreate windows from tauri.conf.json configurations.

Tauri v2 supports multiple webviews in a single window

Tauri v2 adds support for adding multiple webviews to a single window. This feature is currently behind an unstable Cargo feature flag while the API design is being reviewed with the community.

Tauri v2 adds JavaScript APIs for menus and tray icons

Tauri v2 allows configuring window menus and tray icons via JavaScript code, not just Rust. The release also adds APIs to manage the macOS application menu specifically.

Tauri v2 supports native context menus

Tauri v2 implements native context menus with both Rust and JavaScript APIs, powered by the muda library.

Tauri v2 includes new window APIs for app configuration

Tauri v2 implements several new window APIs, making applications more configurable.

Window event system changes

Tauri 2.0 removed tauri::GlobalWindowEvent struct and unpacked its fields to be passed directly to tauri::Builder::on_window_event. tauri::EventHandler type was removed.

Window and Webview types in Tauri 2.0

Tauri 2.0 introduces tauri::WebviewWindow and tauri::WebviewWindowBuilder types. The old tauri::Window and tauri::WindowBuilder behavior has moved to these new types. Corresponding classes are available in JavaScript. On Linux, WebviewWindow provides a default_vbox method to get a reference to the gtk::Box containing the menu bar and webview. On macOS, WebviewWindow provides an ns_view method to get a pointer to the NSWindow content view.

Window constraints applied separately

Tauri 2.0 applies minWidth, minHeight, maxWidth and maxHeight constraints separately. This fixes a long-standing bug where these constraints were never applied unless width and height were constrained together. Methods added include tauri::WindowBuilder::inner_size_constraints, tauri::WebviewWindowBuilder::inner_size_constraints, tauri::WindowSizeConstraints struct, and tauri::Window::set_size_constraints and tauri::WebviewWindow::set_size_constraints methods.

File drop events renamed to drag and drop

Tauri renamed file drop related functionality to drag and drop terminology. tauri::FileDropEvent enum is renamed to tauri::DragDropEvent. tauri::WindowEvent::FileDrop is renamed to tauri::WindowEvent::DragDrop. File drop emitted events are renamed to tauri://drag-enter, tauri://drag-over, tauri://drag-drop, and tauri://drag-leave. tauri::WebviewWindow::disable_file_drop_handler is renamed to tauri::WebviewWindow::disable_drag_drop_handler.

Window close behavior change

Tauri 2.0 changed tauri::WebviewWindow::close to trigger a close requested event instead of forcing the window closed. Use tauri::WebviewWindow::destroy to force close a window.

Webview navigation method

Tauri 2.0 added tauri::WebviewWindow::navigate method to navigate webviews.

Rust environment and menu API changes in v2

`Env.args` field removed, use `Env.args_os` instead. `Menu`, `MenuEvent`, `CustomMenuItem`, `Submenu`, `WindowMenuEvent`, `MenuItem` and `Builder::on_menu_event` APIs removed, use new menu system.

Rust SystemTray API changes in v2

`SystemTray`, `SystemTrayHandle`, `SystemTrayMenu`, `SystemTrayMenuItemHandle`, `SystemTraySubmenu`, `MenuEntry`, and `SystemTrayMenuItem` APIs removed. Use the new tray icon module instead.

Multiwebview support and Window API changes in Tauri v2

Tauri v2 introduces multiwebview support behind an `unstable` feature flag. The Rust window type `Window` renamed to `WebviewWindow`. `WindowBuilder` renamed to `WebviewWindowBuilder`. `WindowUrl` renamed to `WebviewUrl`. Manager's `get_window` function renamed to `get_webview_window`. Window's `parent_window` API renamed to `parent_raw` to support a high-level parent window API. JavaScript `WebviewWindow` type re-exported from `@tauri-apps/api/webviewWindow` instead of `@tauri-apps/api/window`.

Migrate Menu API: use MenuBuilder

Replace `tauri::Menu` with `tauri::menu::MenuBuilder`. The MenuBuilder constructor takes a Manager instance (App, AppHandle, or WebviewWindow) as an argument. Example: `let menu = MenuBuilder::new(app).copy().paste().separator().build()?;`

Migrate Menu API: use PredefinedMenuItem

Replace `tauri::MenuItem` with `tauri::menu::PredefinedMenuItem`. MenuBuilder has dedicated methods for each predefined menu item, so call `.copy()` instead of `.item(&PredefinedMenuItem::copy(app)?)`.

Migrate Menu API: use MenuItemBuilder

Replace `tauri::CustomMenuItem` with `tauri::menu::MenuItemBuilder`. Example: `let toggle = MenuItemBuilder::new("Toggle").accelerator("Ctrl+Shift+T").build(app)?;`

Migrate Menu API: use SubmenuBuilder

Replace `tauri::Submenu` with `tauri::menu::SubmenuBuilder`. Example: `let submenu = SubmenuBuilder::new(app, "Sub").text("Tauri").separator().check("Is Awesome").build()?;`

Migrate Menu API: Builder::menu takes closure

`tauri::Builder::menu` now takes a closure because the menu needs a Manager instance to be constructed. Consult the documentation for more information.

Migrate Menu API: menu event handling

The Rust `tauri::Builder::on_menu_event` API was removed. Use `tauri::App::on_menu_event` or `tauri::AppHandle::on_menu_event` instead. Menu items can be shared between menus, and the menu event is bound to a menu item rather than a menu or window. To avoid triggering all listeners, use dedicated menu item instances instead of sharing them.

Migrate Tray Icon API: use TrayIconBuilder

Replace `tauri::SystemTray` with `tauri::tray::TrayIconBuilder`. Example: `let tray = tauri::tray::TrayIconBuilder::with_id("my-tray").build(app)?;`

Migrate Tray Icon API: use Menu components

Replace `tauri::SystemTrayMenu` with `tauri::menu::Menu`, `tauri::SystemTraySubmenu` with `tauri::menu::Submenu`, and `tauri::SystemTrayMenuItem` with `tauri::menu::PredefinedMenuItem`.

Migrate Tray Icon API: event handling

`tauri::SystemTray::on_event` split into `tauri::tray::TrayIconBuilder::on_menu_event` and `tauri::tray::TrayIconBuilder::on_tray_icon_event`. Handle menu item clicks via `on_menu_event` and tray icon clicks via `on_tray_icon_event` with pattern matching on `TrayIconEvent` for button and button state.

Migrate Window API: type and builder renames

In Rust, rename `Window` to `WebviewWindow`, `WindowBuilder` to `WebviewWindowBuilder`, and `WindowUrl` to `WebviewUrl`. Manager's `get_window` function renamed to `get_webview_window`. Window's `parent_window` API renamed to `parent_raw`.

Migrate Window API: JavaScript export change

In JavaScript, `WebviewWindow` is now exported from `@tauri-apps/api/webviewWindow` instead of `@tauri-apps/api/window`.

Menu and Tray API changes in Tauri v2

Menu and Tray APIs removed in v2: `Menu`, `MenuEvent`, `CustomMenuItem`, `Submenu`, `WindowMenuEvent`, `MenuItem`, `Builder::on_menu_event` APIs removed; use `tauri::menu::MenuBuilder`, `tauri::menu::PredefinedMenuItem`, `tauri::menu::MenuItemBuilder`, and `tauri::menu::SubmenuBuilder` instead. `SystemTray`, `SystemTrayHandle`, `SystemTrayMenu`, `SystemTrayMenuItemHandle`, `SystemTraySubmenu`, and `SystemTrayMenuItem` APIs removed; use `tauri::tray::TrayIconBuilder` instead.

MenuBuilder usage in Tauri v2

Use `tauri::menu::MenuBuilder` to construct menus in Tauri v2. Its constructor requires a Manager instance (App, AppHandle, or Window). Example: `MenuBuilder::new(app).copy().paste().separator().undo().redo().text("open-url", "Open URL").check("toggle", "Toggle").icon("show-app", "Show App", app.default_window_icon().cloned().unwrap()).build()?`

PredefinedMenuItem usage in Tauri v2

Use `tauri::menu::PredefinedMenuItem` instead of `tauri::MenuItem`. Example: `MenuBuilder::new(app).item(&PredefinedMenuItem::copy(app)).build()?`. MenuBuilder has dedicated methods for each predefined menu item, so you can call `.copy()` directly instead of `.item(&PredefinedMenuItem::copy(app, None))`.

MenuItemBuilder usage in Tauri v2

Use `tauri::menu::MenuItemBuilder` instead of `tauri::CustomMenuItem`. Example: `let toggle = MenuItemBuilder::new("Toggle").accelerator("Ctrl+Shift+T").build(app);`

SubmenuBuilder usage in Tauri v2

Use `tauri::menu::SubmenuBuilder` instead of `tauri::Submenu`. Example: `let submenu = SubmenuBuilder::new(app, "Sub").text("Tauri").separator().check("Is Awesome").build()?; let menu = MenuBuilder::new(app).item(&submenu).build()?;`

Menu events in Tauri v2

Use `tauri::App::on_menu_event` or `tauri::AppHandle::on_menu_event` instead of `tauri::Builder::on_menu_event`. Menu items can be shared between menus, and menu events are tied to the item rather than the menu or window. To avoid triggering all listeners, do not share menu items and use dedicated instances that can be moved into closures.

TrayIconBuilder usage in Tauri v2

Use `tauri::tray::TrayIconBuilder` instead of `tauri::SystemTray`. Example: `let tray = tauri::tray::TrayIconBuilder::with_id("my-tray").build(app)?;`

Tray events in Tauri v2

Tray events in v2 are split into `tauri::tray::TrayIconBuilder::on_menu_event` and `tauri::tray::TrayIconBuilder::on_tray_event`. Use `TrayIconEvent` to match tray click events, including MouseButton and MouseButtonState.

Window plugin migration example

To migrate from `@tauri-apps/api/window`, add `tauri-plugin-window = "2"` to Cargo.toml, initialize with `tauri::Builder::default().plugin(tauri_plugin_window::init())`, and in JavaScript use `import { appWindow } from '@tauri-apps/plugin-window'; await appWindow.setTitle('Tauri');`

Managed State access in commands

Tauri manages application state using tauri::Builder's manage function. Commands access managed state using tauri::State<T> parameter. Example: struct MyState(String); #[tauri::command] fn my_custom_command(state: tauri::State<MyState>) { assert_eq!(state.0 == "some state value", true); } Setup in builder: .manage(MyState("some state value".into()))

Tauri v2: Rust Window type renamed to WebviewWindow

In Tauri v2, the Window type is renamed to WebviewWindow, WindowBuilder renamed to WebviewWindowBuilder, and WindowUrl renamed to WebviewUrl. Additionally, Manager::get_window function renamed to get_webview_window, and the window parent_window API renamed to parent_raw.

Tauri v2: Rust Menu API restructured

Menu APIs restructured and refactored using muda crate: Menu and MenuItem APIs moved to tauri::menu module; tauri::menu::MenuBuilder replaces tauri::Menu (requires Manager instance); tauri::menu::PredefinedMenuItem replaces tauri::MenuItem; tauri::menu::MenuItemBuilder replaces tauri::CustomMenuItem; tauri::menu::SubmenuBuilder replaces tauri::Submenu; Builder::menu accepts closure now; Builder::on_menu_event removed (use App::on_menu_event or AppHandle::on_menu_event instead).

Tauri v2: Tray Icon API renamed and restructured

SystemTray API renamed to TrayIcon: SystemTray replaced by tauri::tray::TrayIconBuilder with id parameter; tauri::tray::TrayIconBuilder::with_id() creates tray icons; SystemTrayMenu replaced by tauri::menu::Menu; SystemTraySubmenu replaced by tauri::menu::Submenu; SystemTrayMenuItem replaced by tauri::menu::PredefinedMenuItem; SystemTray::on_event split into TrayIconBuilder::on_menu_event and TrayIconBuilder::on_tray_icon_event.

Tauri v2: multiwebview support

Tauri v2 introduces multiwebview support under unstable feature flag. Window type renamed to WebviewWindow and Manager::get_window renamed to get_webview_window to support this.

Tauri v2: Windows frontend hosting change

Windows production apps now host frontend files at http://tauri.localhost instead of https://tauri.localhost. IndexedDB, LocalStorage, and Cookies are reset unless dangerousUseHttpScheme was used in v1. To prevent reset, set app > windows > useHttpsScheme to true or use WebviewWindowBuilder::use_https_scheme.

Tauri v2: Menu API builder with context manager

MenuBuilder requires a Manager instance (App, AppHandle, or WebviewWindow) as constructor argument. Example: let menu = MenuBuilder::new(app).copy().paste().text("id", "Label").build()?. PredefinedMenuItem usage: MenuBuilder::new(app).item(&PredefinedMenuItem::copy(app)?).build()?

Tauri v2: custom menu item creation

Custom menu items created with MenuItemBuilder: let item = MenuItemBuilder::with_id("id", "Label").accelerator("Ctrl+X").build(app)?. For submenus, use SubmenuBuilder: let sub = SubmenuBuilder::new(app, "Sub").text("Item").build()?

Tauri v2: Tray Icon builder with menu events

Tray icon created with: let tray = TrayIconBuilder::new().menu(&menu).on_menu_event(|app, event| { ... }).on_tray_icon_event(|tray, event| { ... }).build(app)?. Separate handlers for menu events and tray icon events (click, hover, etc.).

Tauri v2: menu event handler with item ID matching

Menu event handler matches items by ID: app.on_menu_event(move |app, event| { if event.id() == check.id() { println!("checked? {}", check.is_checked().unwrap()); } else if event.id() == "toggle" { println!("toggle triggered"); } });. Item IDs can be retrieved from item object or set via MenuItemBuilder::with_id()

Give your agent this brain