Primitives: clicking a pick field no longer jumps to the Diameter box (#10428) (#10536)

* claim: #10428

Signed-off-by: Maurizio Monticelli <maurizio@whatwedo.ch>

* Primitives: a pick field waits for its pick and says what it is for

Clicking Face, Reference 1 or 2 in the Cylinder window, or Point in the
Box, Sphere and Torus windows, and then clicking something the field
does not take (empty space, the cylinder's own preview) gave the
keyboard to Diameter, so the field no longer looked active and nothing
said why the click picked nothing. A pick field clicked into now keeps
the keyboard until a click picks something, and a click it does not
take leaves a note under the form saying what the field is for.

These fields also get their own tooltips: Face is the face or vertex
the cylinder stands on, Reference 1 and 2 are straight edges of that
face the distances below are measured from, and Point is a vertex,
edge, face, sketch point or the origin whose point fills X, Y and Z.

Fixes #10428

Signed-off-by: Maurizio Monticelli <maurizio@whatwedo.ch>

---------

Signed-off-by: Maurizio Monticelli <maurizio@whatwedo.ch>
This commit is contained in:
rugbymauri
2026-11-04 22:04:36 +00:00
committed by GitHub
parent 2396b6be05
commit 2998d412b6
8 changed files with 203 additions and 10 deletions
@@ -0,0 +1,62 @@
{
"en": {
"dialog.cylinder_face_tip": "The face or vertex of the model the cylinder stands on: click here, then click it in the view. Left empty, X, Y and Z place it.",
"dialog.primitive_point_tip": "A point that fills X, Y and Z: click here, then click a vertex, edge or face of the model, a point of a sketch, or the origin.",
"dialog.reference_edge_tip": "A straight edge of the picked face to measure the distance below from: click here, then click the edge."
},
"ar": {
"dialog.cylinder_face_tip": "وجه النموذج أو رأسه الذي تقوم عليه الأسطوانة: انقر هنا ثم انقر عليه في العرض. إذا تُرك فارغًا، تحدد X وY وZ موضعها.",
"dialog.primitive_point_tip": "نقطة تملأ X وY وZ: انقر هنا ثم على رأس أو حافة أو وجه من النموذج، أو على نقطة من رسم، أو على نقطة الأصل.",
"dialog.reference_edge_tip": "حافة مستقيمة من الوجه المختار تُقاس منها المسافة أدناه: انقر هنا ثم على الحافة."
},
"de": {
"dialog.cylinder_face_tip": "Die Fläche oder der Eckpunkt des Modells, auf dem der Zylinder steht: hier klicken, dann in der Ansicht darauf klicken. Leer gelassen platzieren ihn X, Y und Z.",
"dialog.primitive_point_tip": "Ein Punkt, der X, Y und Z füllt: hier klicken, dann einen Eckpunkt, eine Kante oder Fläche des Modells, einen Punkt einer Skizze oder den Ursprung anklicken.",
"dialog.reference_edge_tip": "Eine gerade Kante der gewählten Fläche, von der aus der Abstand darunter gemessen wird: hier klicken, dann die Kante anklicken."
},
"es": {
"dialog.cylinder_face_tip": "La cara o el vértice del modelo sobre el que se apoya el cilindro: haz clic aquí y después haz clic en él en la vista. Si se deja vacío, lo colocan X, Y y Z.",
"dialog.primitive_point_tip": "Un punto que rellena X, Y y Z: haz clic aquí y después en un vértice, una arista o una cara del modelo, en un punto de un boceto o en el origen.",
"dialog.reference_edge_tip": "Una arista recta de la cara elegida desde la que se mide la distancia de abajo: haz clic aquí y después en la arista."
},
"fr": {
"dialog.cylinder_face_tip": "La face ou le sommet du modèle sur lequel le cylindre est posé : cliquer ici, puis dessus dans la vue. Laissé vide, X, Y et Z le placent.",
"dialog.primitive_point_tip": "Un point qui remplit X, Y et Z : cliquer ici, puis sur un sommet, une arête ou une face du modèle, sur un point d'une esquisse ou sur l'origine.",
"dialog.reference_edge_tip": "Une arête droite de la face choisie, depuis laquelle la distance ci-dessous est mesurée : cliquer ici, puis sur l'arête."
},
"he": {
"dialog.cylinder_face_tip": "הפאה או הקודקוד של המודל שעליהם הגליל ניצב: יש ללחוץ כאן ואז עליהם בתצוגה. אם נשאר ריק, X, Y ו-Z ממקמים אותו.",
"dialog.primitive_point_tip": "נקודה שממלאת את X, Y ו-Z: יש ללחוץ כאן ואז על קודקוד, מקצוע או פאה של המודל, על נקודה של סקיצה, או על הראשית.",
"dialog.reference_edge_tip": "מקצוע ישר של הפאה שנבחרה שממנו נמדד המרחק שלמטה: יש ללחוץ כאן ואז על המקצוע."
},
"it": {
"dialog.cylinder_face_tip": "La faccia o il vertice del modello su cui poggia il cilindro: fai clic qui, poi su di esso nella vista. Se resta vuoto, lo posizionano X, Y e Z.",
"dialog.primitive_point_tip": "Un punto che compila X, Y e Z: fai clic qui, poi su un vertice, uno spigolo o una faccia del modello, su un punto di uno schizzo oppure sull'origine.",
"dialog.reference_edge_tip": "Uno spigolo rettilineo della faccia scelta da cui si misura la distanza sotto: fai clic qui, poi sullo spigolo."
},
"ja": {
"dialog.cylinder_face_tip": "円柱が立つモデルの面または頂点: ここをクリックしてから、ビューでそれをクリック。空のままなら X、Y、Z で配置します。",
"dialog.primitive_point_tip": "X、Y、Z を埋める点: ここをクリックしてから、モデルの頂点、エッジ、面、スケッチの点、または原点をクリック。",
"dialog.reference_edge_tip": "下の距離を測る基準となる、選んだ面の直線エッジ: ここをクリックしてからエッジをクリック。"
},
"ko": {
"dialog.cylinder_face_tip": "원기둥이 놓일 모델의 면 또는 꼭짓점: 여기를 클릭한 다음 뷰에서 그것을 클릭. 비워 두면 X, Y, Z로 배치합니다.",
"dialog.primitive_point_tip": "X, Y, Z를 채우는 점: 여기를 클릭한 다음 모델의 꼭짓점, 모서리, 면, 스케치의 점 또는 원점을 클릭.",
"dialog.reference_edge_tip": "아래 거리를 재는 기준이 되는, 선택한 면의 직선 모서리: 여기를 클릭한 다음 모서리를 클릭."
},
"vi": {
"dialog.cylinder_face_tip": "Bề mặt hoặc đỉnh của mô hình mà khối trụ đứng trên đó: nhấp vào đây, sau đó nhấp vào nó trong khung nhìn. Để trống thì X, Y và Z đặt vị trí.",
"dialog.primitive_point_tip": "Một điểm điền vào X, Y và Z: nhấp vào đây, sau đó nhấp vào một đỉnh, cạnh hoặc bề mặt của mô hình, một điểm của bản phác thảo, hoặc gốc tọa độ.",
"dialog.reference_edge_tip": "Một cạnh thẳng của bề mặt đã chọn, từ đó đo khoảng cách bên dưới: nhấp vào đây, sau đó nhấp vào cạnh."
},
"zh": {
"dialog.cylinder_face_tip": "圆柱体所立的模型面或顶点:先单击此处,再在视图中单击它。留空时由 X、Y、Z 放置。",
"dialog.primitive_point_tip": "填入 X、Y、Z 的点:先单击此处,再单击模型的顶点、边或面、草图中的点,或原点。",
"dialog.reference_edge_tip": "所选面上的一条直边,下方的距离从它量起:先单击此处,再单击该边。"
},
"zh-TW": {
"dialog.cylinder_face_tip": "圓柱體所立的模型面或頂點:先點擊此處,再在視圖中點擊它。留空時由 X、Y、Z 放置。",
"dialog.primitive_point_tip": "填入 X、Y、Z 的點:先點擊此處,再點擊模型的頂點、邊或面、草圖中的點,或原點。",
"dialog.reference_edge_tip": "所選面上的一條直邊,下方的距離從它量起:先點擊此處,再點擊該邊。"
}
}
@@ -0,0 +1 @@
| assets/locales/pending/primitive-pick-field-tips.json | SolidCraft contributors | Original primitive pick-field tooltip translations | MIT OR Apache-2.0 |
+46 -4
View File
@@ -514,6 +514,12 @@ pub struct Dialog {
value_focus: Option<egui::Id>,
/// A viewport press or click returns the keyboard after selection and canvas updates.
pub(crate) restore_value_focus: bool,
/// A pick field was clicked into and waits for its pick: a click in the view that picks
/// nothing leaves the keyboard with it instead of giving it to the first value (#10428).
pub(crate) awaiting_pick: bool,
/// The note (a message id) a click that the waiting pick field does not take leaves under
/// the form: what that field is for (#10428).
pub(crate) pick_refused: Option<&'static str>,
/// Folded to its header (the shared disclosure chevron).
pub collapsed: bool,
reset_scroll: bool,
@@ -795,6 +801,8 @@ impl Dialog {
focus: true,
value_focus: None,
restore_value_focus: false,
awaiting_pick: false,
pick_refused: None,
collapsed: false,
reset_scroll: true,
preview_enabled: true,
@@ -1725,6 +1733,8 @@ impl Dialog {
/// A pick in the viewport (already accepted by the active input).
pub fn pick(&mut self, s: &Session, sel: Sel) {
self.awaiting_pick = false;
self.pick_refused = None;
if self.take_extrude_target(s, &sel) {
return;
}
@@ -1823,6 +1833,7 @@ impl Dialog {
if !add {
inp.items.clear();
}
let mut accepted = false;
for x in sels {
if takes_components {
let occ = match x {
@@ -1830,10 +1841,11 @@ impl Dialog {
Sel::Body { name } => occurrence_path_of_body(s, &name).map(|path| Sel::Occurrence { path }),
_ => None,
};
if let Some(occ) = occ
&& !inp.items.contains(&occ)
{
inp.items.push(occ);
if let Some(occ) = occ {
accepted = true;
if !inp.items.contains(&occ) {
inp.items.push(occ);
}
}
continue;
}
@@ -1841,6 +1853,7 @@ impl Dialog {
if !fits(inp.accept, &x) {
continue;
}
accepted = true;
if !inp.multi {
inp.items.clear();
inp.items.push(x);
@@ -1859,6 +1872,11 @@ impl Dialog {
inp.items.push(x);
}
}
// A marquee that took something is the pick a waiting pick field waited for (#10428).
if accepted {
self.awaiting_pick = false;
self.pick_refused = None;
}
self.sync_thread(s);
self.sync_material(s);
}
@@ -3011,6 +3029,8 @@ pub(crate) fn input_rows_range(d: &mut Dialog, ui: &mut egui::Ui, s: &Session, n
} else {
hint(inp).to_string()
}
} else if let Some(id) = inp.tip {
crate::i18n::tr(id).to_string()
} else {
format!("{} (click to pick into this input)", hint(inp))
};
@@ -3081,6 +3101,8 @@ pub(crate) fn input_rows_range(d: &mut Dialog, ui: &mut egui::Ui, s: &Session, n
if let Kind::Extrude { smart, .. } = &mut d.kind {
smart.profiles_chosen = i == 0;
}
d.awaiting_pick = true;
d.pick_refused = None;
}
if let Some(i) = clear {
if let Some(key) = stored_input_reference_key(d, i) {
@@ -3097,6 +3119,8 @@ pub(crate) fn input_rows_range(d: &mut Dialog, ui: &mut egui::Ui, s: &Session, n
d.picked_edges.clear();
}
d.active = i;
d.awaiting_pick = true;
d.pick_refused = None;
}
d.sync_thread(s);
}
@@ -3159,6 +3183,19 @@ fn error_rows(app: &mut SolveApp, ctx: &egui::Context, d: &mut Dialog, ui: &mut
if d.error.is_none() && app.preview.error.is_none() {
ui.data_mut(|m| m.remove::<String>(shown_id));
}
// A click the waiting pick field does not take: what that field is for, plainly (#10428).
// Under the fold in a short window, a new note scrolls into view once, as a refusal does.
let note_shown_id = egui::Id::new("sc_dialog_pick_refused_shown");
if let Some(id) = d.pick_refused.filter(|_| d.error.is_none() && app.preview.error.is_none()) {
let note = crate::ui_kit::text(ui, crate::i18n::tr(id), crate::ui_kit::Text::Hint("pick_refused"));
crate::scenario::publish_rect("dialog:pick_refused", note.rect);
if ui.data(|m| m.get_temp::<&'static str>(note_shown_id)) != Some(id) {
ui.scroll_to_rect(note.rect, None);
ui.data_mut(|m| m.insert_temp(note_shown_id, id));
}
} else {
ui.data_mut(|m| m.remove::<&'static str>(note_shown_id));
}
if let Some(error) = d.error.as_ref().or(app.preview.error.as_ref()).cloned() {
// "Select the curves to offset first" is not a failure: nothing is picked yet. The header hint
// and the disabled OK already say so, so it is not drawn as a red error with an issue button.
@@ -3926,6 +3963,11 @@ pub fn show(app: &mut SolveApp, ctx: &egui::Context) {
ctx.request_repaint();
} else {
d.value_focus = ctx.memory(|memory| memory.focused()).filter(|id| value_fields.iter().any(|(field, _)| field == id));
// A value field clicked into: the pick field no longer waits.
if d.value_focus.is_some() {
d.awaiting_pick = false;
d.pick_refused = None;
}
}
// Each prompt draws only for its own dialog, so both run (`|`, not `||`).
let preset_prompt = crate::hole_presets::name_prompt(ctx, &mut d, &mut app.preferences.hole_presets, &app.session.doc)
+2 -2
View File
@@ -74,12 +74,12 @@ struct Framed {
/// The reference edge inputs a Single hole's dialog has after its face input.
pub(crate) fn inputs() -> [SelInput; 2] {
REFERENCES.map(|label| SelInput::new(label, EDGES, false))
REFERENCES.map(|label| SelInput::new(label, EDGES, false).tip("dialog.reference_edge_tip"))
}
/// The Cylinder window's inputs: where it stands (a face, or a vertex), then the reference edges.
pub(crate) fn cylinder_inputs() -> Vec<SelInput> {
let mut v = vec![SelInput::new("Face", PLANAR_FACES | FACES | VERTICES, false)];
let mut v = vec![SelInput::new("Face", PLANAR_FACES | FACES | VERTICES, false).tip("dialog.cylinder_face_tip")];
v.extend(inputs());
v
}
+72
View File
@@ -323,3 +323,75 @@ fn a_cylinder_started_first_takes_its_face_then_its_edges() {
let FeatureKind::Cylinder { references, .. } = &f.kind else { panic!("the last feature is a cylinder") };
assert_eq!(references.len(), 2);
}
/// Clicked into, a pick field keeps the keyboard until a click picks something (#10428): a click
/// that picks nothing (off the model) leaves it waiting and says what it is for, instead of giving
/// the keyboard to Diameter; the next click on a face fills it. Each placement field of the
/// primitives says what it is for.
#[test]
fn a_pick_field_clicked_into_waits_for_its_pick_and_says_what_it_takes() {
let mut h = plate();
h.step(&json!({"start": "solid.cylinder"})).unwrap();
h.frames(2);
h.step(&json!({"click": {"handle": "dialog:Face"}})).unwrap();
h.frames(2);
let off = screen(&mut h, Vec3::new(-8.0, 20.0, 0.0));
h.step(&json!({"click": off})).unwrap();
h.frames(3);
let d = h.app.dialog.as_ref().unwrap();
assert_eq!((d.active, d.awaiting_pick), (0, true), "Face still waits for its pick");
assert!(d.inputs[0].items.is_empty(), "nothing was picked off the model");
assert_eq!(d.pick_refused, Some("dialog.cylinder_face_tip"));
assert!(crate::scenario::rect_of("dialog:pick_refused").is_some(), "the note shows under the form");
assert_eq!(h.ctx.memory(|m| m.focused()), None, "no value field took the keyboard");
let at = screen(&mut h, Vec3::new(30.0, 25.0, 10.0));
h.step(&json!({"click": at})).unwrap();
h.frames(2);
assert!(cylinder_dialog(&h).1.dist(Vec3::new(30.0, 25.0, 10.0)) < 0.5, "the face is picked: {:?}", cylinder_dialog(&h).1);
let d = h.app.dialog.as_ref().unwrap();
assert_eq!((d.awaiting_pick, d.pick_refused), (false, None));
let tips: Vec<_> = crate::hole_refs::cylinder_inputs().iter().map(|i| i.tip).collect();
assert_eq!(tips, [Some("dialog.cylinder_face_tip"), Some("dialog.reference_edge_tip"), Some("dialog.reference_edge_tip")]);
for cmd in ["solid.box", "solid.sphere", "solid.torus"] {
let tips: Vec<_> = crate::primitive_placement::inputs(cmd).iter().map(|i| i.tip).collect();
assert_eq!(tips, [Some("dialog.primitive_point_tip")], "{cmd}");
}
for id in ["dialog.cylinder_face_tip", "dialog.reference_edge_tip", "dialog.primitive_point_tip"] {
assert_ne!(crate::i18n::tr(id), id, "{id} is in the catalog");
}
}
/// The note a refused click leaves goes once the pick field stops waiting (#10428): when a value
/// field is clicked into, and when a marquee takes something into the field; a marquee that takes
/// nothing leaves the field waiting and the note shown. A new note scrolls into view once.
#[test]
fn a_pick_fields_note_goes_with_a_value_field_or_a_marquee_that_takes_something() {
let note_shown = egui::Id::new("sc_dialog_pick_refused_shown");
let mut h = plate();
h.step(&json!({"start": "solid.cylinder"})).unwrap();
h.frames(2);
h.step(&json!({"click": {"handle": "dialog:Face"}})).unwrap();
h.frames(2);
let off = screen(&mut h, Vec3::new(-8.0, 20.0, 0.0));
h.step(&json!({"click": off})).unwrap();
h.frames(3);
assert_eq!(h.app.dialog.as_ref().unwrap().pick_refused, Some("dialog.cylinder_face_tip"));
assert_eq!(h.ctx.data(|m| m.get_temp::<&'static str>(note_shown)), Some("dialog.cylinder_face_tip"), "the note was scrolled to");
h.step(&json!({"click": {"handle": "dialog:ui.diameter"}})).unwrap();
h.frames(2);
let d = h.app.dialog.as_ref().unwrap();
assert_eq!((d.awaiting_pick, d.pick_refused), (false, None), "a value field clicked into ends the wait and its note");
assert!(crate::scenario::rect_of("dialog:pick_refused").is_none(), "the note is gone");
let d = h.app.dialog.as_mut().unwrap();
d.active = 0;
d.awaiting_pick = true;
d.pick_refused = Some("dialog.cylinder_face_tip");
d.take_box(&h.app.session, Vec::new(), false);
assert_eq!((d.awaiting_pick, d.pick_refused), (true, Some("dialog.cylinder_face_tip")), "a marquee that takes nothing keeps both");
let face = Sel::Face { body: "Body".into(), index: 0, point: Vec3::new(30.0, 25.0, 10.0) };
d.take_box(&h.app.session, vec![face], false);
assert!(!d.inputs[0].items.is_empty(), "the marquee took the face");
assert_eq!((d.awaiting_pick, d.pick_refused), (false, None), "a marquee that takes something ends the wait and its note");
}
+1 -1
View File
@@ -40,7 +40,7 @@ const BOX_PLACEMENTS: [&str; 2] = ["Corner", "Center"];
pub(crate) fn inputs(cmd: &str) -> Vec<SelInput> {
match cmd {
"solid.box" | "solid.sphere" | "solid.torus" => {
vec![SelInput::new("Point", VERTICES | EDGES | FACES | ORIGIN | POINTS | EXTERNAL_POINTS, false)]
vec![SelInput::new("Point", VERTICES | EDGES | FACES | ORIGIN | POINTS | EXTERNAL_POINTS, false).tip("dialog.primitive_point_tip")]
}
_ => Vec::new(),
}
+10 -1
View File
@@ -99,12 +99,15 @@ pub struct SelInput {
/// Face picks are places on the face, not the face: several on one face add up (a click on
/// the very spot of one takes it out). For points that pick pieces a face is cut into.
pub places: bool,
/// What the input is for, as a message id: its tooltip, and the note a click that picks
/// nothing leaves under the form (#10428). Without one the tooltip names what it takes.
pub tip: Option<&'static str>,
pub items: Vec<Sel>,
}
impl SelInput {
pub fn new(label: &'static str, accept: Accept, multi: bool) -> SelInput {
SelInput { label, accept, multi, places: false, items: Vec::new() }
SelInput { label, accept, multi, places: false, tip: None, items: Vec::new() }
}
/// This input with face picks as places (see [`SelInput::places`]).
@@ -113,6 +116,12 @@ impl SelInput {
self
}
/// This input with a tooltip saying what it is for (see [`SelInput::tip`]).
pub fn tip(mut self, id: &'static str) -> SelInput {
self.tip = Some(id);
self
}
/// The selection a hit stands for, if this input accepts it. A curve of another sketch than
/// the `active` one names its sketch: curve ids repeat from one sketch to the next (#3726).
pub fn accepts(&self, h: &Hit, active: Option<u64>, planar: impl Fn(&str, usize) -> bool) -> Option<Sel> {
+9 -2
View File
@@ -3564,6 +3564,8 @@ pub(crate) fn dialog_pick(app: &mut SolveApp, hit: &Hit, sel: Sel) {
// With holes moving by clicking (Preferences), a Single hole picked again on its face moves there.
if app.preferences.hole_moves && crate::hole_place::pick_moves(&mut d, &app.session, &sel) {
d.focus = true;
d.awaiting_pick = false;
d.pick_refused = None;
} else {
d.pick(&app.session, sel);
}
@@ -5007,11 +5009,12 @@ pub fn show(app: &mut SolveApp, ui: &mut egui::Ui) {
&& app.dialog.is_none()
&& crate::dim_view::pick_reference(app, ui.ctx(), p, resp.double_clicked());
// Capture the press too: text editors lose focus before the click is released. A
// running tool keeps the keyboard for its own typed values.
// running tool keeps the keyboard for its own typed values, and so does a pick field
// clicked into until a click picks something (#10428).
if !held
&& app.tool.is_none()
&& (resp.clicked() || (resp.contains_pointer() && ui.input(|i| i.pointer.primary_pressed())))
&& let Some(dialog) = app.dialog.as_mut()
&& let Some(dialog) = app.dialog.as_mut().filter(|d| !d.awaiting_pick)
{
dialog.restore_value_focus = true;
}
@@ -5024,6 +5027,10 @@ pub fn show(app: &mut SolveApp, ui: &mut egui::Ui) {
if let Some((hit, Some(sel))) = cand {
dialog_pick(app, &hit, sel);
} else if let Some(mut dialog) = app.dialog.take() {
// A pick field clicked into says what it is for when the click is not one (#10428).
if dialog.awaiting_pick {
dialog.pick_refused = dialog.active_input().and_then(|i| i.tip);
}
// A sketch clicked for a pattern's or Mirror's objects: say why it is not taken (#10057).
let sketch = hits.iter().find_map(|h| match h {
Hit::SketchCurve { sketch, .. } | Hit::SketchPoint { sketch, .. } | Hit::Profile { sketch, .. } => Some(*sketch),