Red round 3: keep keyboard focus unless the primary button clicked a host target

This commit is contained in:
skylartaylor
2026-11-23 12:24:14 +01:00
parent 86284b540e
commit 11db5e69a5
+2 -2
View File
@@ -151,8 +151,8 @@ pub(crate) fn target(ui: &mut Ui, key: impl Hash + std::fmt::Debug, rect: Rect,
let out = control.show_at(ui, rect);
// A pointer click acts and leaves no keyboard focus behind, as the raw click targets these replace did: a focused
// control makes the shell treat the next Escape as a text field's, so Escape would not go back from the photo.
// A key activation keeps its focus.
if out.clicked() && !out.by_key {
// Only a primary-button click does: a right-click opens its menu from this target. A key activation keeps its focus.
if out.clicked() && !out.by_key && ui.input(|input| input.pointer.button_released(egui::PointerButton::Primary)) {
ui.ctx().memory_mut(|memory| memory.surrender_focus(out.response.id));
}
out