Shapes: the Gradient Editor uses the shared colour picker; Escape closes only the picker (#612)
The stop colour now uses widgets::srgb_color_button, the After Effects-style picker every colour input opens (#638): hex field, HSB/RGB fields, OK and Cancel, sRGB as the project stores colours. The stop keeps its alpha. The dialog Escape handler only stepped aside for egui popups, and this picker isn't one, so in a modal dialog Escape with the picker open closed the dialog too. The picker now marks the pass it was open in (color_picker::open_recently), and the handler leaves Escape to it: Escape restores the colour the picker opened with and closes only the picker. Tests: ui_gradient_editor clicks inside the picker's colour field over the modal editor, types a hex code, closes the picker by clicking outside it and saves the stop; a new test checks that Escape and the picker's Cancel restore the stop's colour and keep the editor and its other edits. That test fails without the Escape change. ui_color_hex still passes.
This commit is contained in:
@@ -1608,7 +1608,8 @@ fn handle_shortcuts_impl(app: &mut EffectcraftApp, ctx: &egui::Context, tab_only
|
||||
let start = modifiers_at_start(ctx);
|
||||
// Dialog cancellation owns Escape even when a text field has keyboard focus.
|
||||
if !tab_only && app.dialog.is_some() && ctx.input(|i| i.key_pressed(egui::Key::Escape)) {
|
||||
if crate::panels::shortcut_editor::recording(app) || egui::Popup::is_any_open(ctx) {
|
||||
// A popup or colour picker takes Escape first (the picker goes back to its original colour).
|
||||
if crate::panels::shortcut_editor::recording(app) || egui::Popup::is_any_open(ctx) || crate::color_picker::open_recently(ctx) {
|
||||
return;
|
||||
}
|
||||
ctx.input_mut(|i| i.consume_key(egui::Modifiers::NONE, egui::Key::Escape));
|
||||
|
||||
Reference in New Issue
Block a user