mirror of
https://github.com/storytold/vectorcraft.git
synced 2026-12-01 02:35:37 +01:00
Tangent Circle Tool: a second click opens the radius dialog as a new held dialog
The dialog host now ties each held record to one opening of a dialog, and drops a record whose dialog was opened again under the same id. Reopening the radius dialog straight through the host left the new opening with no record, so its Cancel never cleared the open dialog (a_second_click_replaces_the_open_dialog failed). The dialog now opens the replacement with open_held_with, which gives it its own OK and cancel hook.
This commit is contained in:
1 parent
d8a02e74bf
commit
f0b6f5208a
1 file changed
+2
-9
@@ -51,16 +51,13 @@ pub(crate) fn open(app: &mut VectorcraftApp, p: &Value) {
|
||||
return;
|
||||
};
|
||||
// A dialog still open from an earlier click closes without an answer, and its preview is rolled back. The new
|
||||
// dialog has its id (the dialog's kind), so the earlier dialog's held answer, with its OK and cancel hook, serves
|
||||
// the new one.
|
||||
let mut held = None;
|
||||
// dialog has the same id (the dialog's kind), and its own held answer and cancel hook replace the earlier ones.
|
||||
if let Some(mut old) = app.addon_dialogs.tangent_radius.take() {
|
||||
if let Some(host) = app.dialogs() {
|
||||
host.with(|h| {
|
||||
h.cancel_by_id(&ctx, old.id);
|
||||
let _ = h.take_by_id::<HostedParamDialog>(old.id);
|
||||
});
|
||||
held = Some(host);
|
||||
}
|
||||
take_preview(app, &mut old).cancel(app);
|
||||
}
|
||||
@@ -76,11 +73,7 @@ pub(crate) fn open(app: &mut VectorcraftApp, p: &Value) {
|
||||
take_preview(app, &mut open).cancel(app);
|
||||
}
|
||||
});
|
||||
let opened = match held {
|
||||
Some(host) => Some(host.with(|h| h.open(dialog.held_ok()))),
|
||||
None => open_held_with(app, dialog, ok, HeldOptions { parent: None, cancel: Some(cancel) }),
|
||||
};
|
||||
match opened {
|
||||
match open_held_with(app, dialog, ok, HeldOptions { parent: None, cancel: Some(cancel) }) {
|
||||
Some(id) => {
|
||||
app.addon_dialogs.tangent_radius =
|
||||
Some(Open { id, click: p.clone(), doc, tried: None, note: None, preview: LivePreview::default(), shown_in: doc });
|
||||
|
||||
Reference in new issue
Block a user