mirror of
https://github.com/storytold/vectorcraft.git
synced 2026-12-01 02:35:37 +01:00
Title bar: send the caption Close through the window host
The close the Close caption button asks for goes through WindowHost::act with WindowAction::Close, the sender the title bar uses for Minimize and Maximize, in place of a raw ViewportCommand::Close.
This commit is contained in:
1 parent
a4bd07c896
commit
a7e20825da
1 file changed
+6
-5
@@ -10,7 +10,7 @@ use craft::ui::contract::{Bind, BodyCx, Props, Show, ShowContainer};
|
||||
use craft::ui::display::Picture;
|
||||
use craft::ui::layout_components::Row;
|
||||
use craft::ui::primitives::IconSpec;
|
||||
use craft::ui::runtime::windows::WindowHost;
|
||||
use craft::ui::runtime::windows::{WindowAction, WindowHost};
|
||||
use craft::ui::shell::{Frame, Title, TitleBar};
|
||||
use craft::ui::style::{SurfaceKind, Variant};
|
||||
use egui::Ui;
|
||||
@@ -144,11 +144,12 @@ pub fn app_bar(ui: &mut Ui, _cx: &mut BodyCx<'_>, app: &mut VectorcraftApp) {
|
||||
} else {
|
||||
TitleBar::new().surface(SurfaceKind::Background).show_fitted(ui, start, end)
|
||||
};
|
||||
// The title bar reports a caption Close click in its output and never acts on it; acting here
|
||||
// keeps the click from being dropped (the unsaved-changes prompt runs from the close request
|
||||
// the command raises, as an OS close does).
|
||||
// The title bar reports a caption Close click in its output and never acts on it. The window host sends the close,
|
||||
// and a close of the main window goes through the app's close guard, so the unsaved-changes prompt runs as it does
|
||||
// for an OS close.
|
||||
if out.close_requested {
|
||||
ui.ctx().send_viewport_cmd(egui::ViewportCommand::Close);
|
||||
let ctx = ui.ctx().clone();
|
||||
WindowHost::of(&ctx).act(ctx.viewport_id(), WindowAction::Close);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user