mirror of
https://github.com/servo/servo.git
synced 2025-08-08 15:05:35 +01:00
servoshell: make the color picker and select picker closeable (#38373)
Addresses the first half of #38347 by making it possible to close the select picker and the color picker by pressing ESC or clicking off the modal. Marking this as draft since I need some help with squashing a bug - the "clicking off" part only triggers after moving the mouse or pressing any key, and I'm not sure why. Testing: Manual. Fixes: First half of #38347. --------- Signed-off-by: lumiscosity <averyrudelphe@gmail.com>
This commit is contained in:
parent
98522db8be
commit
757dbc0eda
1 changed files with 64 additions and 44 deletions
|
@ -500,10 +500,15 @@ impl Dialog {
|
|||
if clickable_area.hovered() && option.is_disabled {
|
||||
ui.ctx().set_cursor_icon(egui::CursorIcon::NotAllowed);
|
||||
}
|
||||
|
||||
if ui.ctx().input(|i| i.key_pressed(egui::Key::Escape)) {
|
||||
*is_open = false;
|
||||
}
|
||||
}
|
||||
|
||||
let modal = Modal::new("select_element_picker".into()).area(area);
|
||||
modal.show(ctx, |ui| {
|
||||
let backdrop_response = modal
|
||||
.show(ctx, |ui| {
|
||||
egui::ScrollArea::vertical().show(ui, |ui| {
|
||||
for option_or_optgroup in prompt.options() {
|
||||
match &option_or_optgroup {
|
||||
|
@ -532,7 +537,13 @@ impl Dialog {
|
|||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
})
|
||||
.backdrop_response;
|
||||
|
||||
//FIXME: Doesn't update until you move your mouse or press a key - why?
|
||||
if backdrop_response.clicked() {
|
||||
is_open = false;
|
||||
}
|
||||
|
||||
prompt.select(selected_option);
|
||||
|
||||
|
@ -560,7 +571,8 @@ impl Dialog {
|
|||
.fixed_pos(egui::pos2(position.min.x as f32, position.max.y as f32));
|
||||
|
||||
let modal = Modal::new("select_element_picker".into()).area(area);
|
||||
modal.show(ctx, |ui| {
|
||||
let backdrop_response = modal
|
||||
.show(ctx, |ui| {
|
||||
egui::widgets::color_picker::color_picker_color32(
|
||||
ui,
|
||||
current_color,
|
||||
|
@ -569,7 +581,9 @@ impl Dialog {
|
|||
|
||||
ui.add_space(10.);
|
||||
|
||||
if ui.button("Dismiss").clicked() {
|
||||
if ui.button("Dismiss").clicked() ||
|
||||
ui.input(|i| i.key_pressed(egui::Key::Escape))
|
||||
{
|
||||
is_open = false;
|
||||
prompt.select(None);
|
||||
}
|
||||
|
@ -582,7 +596,13 @@ impl Dialog {
|
|||
};
|
||||
prompt.select(Some(selected_color));
|
||||
}
|
||||
});
|
||||
})
|
||||
.backdrop_response;
|
||||
|
||||
//FIXME: Doesn't update until you move your mouse or press a key - why?
|
||||
if backdrop_response.clicked() {
|
||||
is_open = false;
|
||||
}
|
||||
|
||||
is_open
|
||||
},
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue