mirror of
https://github.com/servo/servo.git
synced 2025-08-10 07:55:33 +01:00
servoshell: Allow keyboard interaction with dialogs (enter / escape) (#35673)
Signed-off-by: L Ashwin B <lashwinib@gmail.com>
This commit is contained in:
parent
c6527c4118
commit
52119c339c
1 changed files with 33 additions and 11 deletions
|
@ -153,7 +153,9 @@ impl Dialog {
|
||||||
ui,
|
ui,
|
||||||
|_ui| {},
|
|_ui| {},
|
||||||
|ui| {
|
|ui| {
|
||||||
if ui.button("Close").clicked() {
|
if ui.button("Close").clicked() ||
|
||||||
|
ui.input(|i| i.key_pressed(egui::Key::Escape))
|
||||||
|
{
|
||||||
is_open = false;
|
is_open = false;
|
||||||
if let Err(e) = response_sender.send(AlertResponse::Ok) {
|
if let Err(e) = response_sender.send(AlertResponse::Ok) {
|
||||||
warn!("Failed to send alert dialog response: {}", e);
|
warn!("Failed to send alert dialog response: {}", e);
|
||||||
|
@ -176,13 +178,17 @@ impl Dialog {
|
||||||
ui,
|
ui,
|
||||||
|_ui| {},
|
|_ui| {},
|
||||||
|ui| {
|
|ui| {
|
||||||
if ui.button("Ok").clicked() {
|
if ui.button("Ok").clicked() ||
|
||||||
|
ui.input(|i| i.key_pressed(egui::Key::Enter))
|
||||||
|
{
|
||||||
is_open = false;
|
is_open = false;
|
||||||
if let Err(e) = response_sender.send(ConfirmResponse::Ok) {
|
if let Err(e) = response_sender.send(ConfirmResponse::Ok) {
|
||||||
warn!("Failed to send alert dialog response: {}", e);
|
warn!("Failed to send alert dialog response: {}", e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ui.button("Cancel").clicked() {
|
if ui.button("Cancel").clicked() ||
|
||||||
|
ui.input(|i| i.key_pressed(egui::Key::Escape))
|
||||||
|
{
|
||||||
is_open = false;
|
is_open = false;
|
||||||
if let Err(e) = response_sender.send(ConfirmResponse::Cancel) {
|
if let Err(e) = response_sender.send(ConfirmResponse::Cancel) {
|
||||||
warn!("Failed to send alert dialog response: {}", e);
|
warn!("Failed to send alert dialog response: {}", e);
|
||||||
|
@ -206,7 +212,9 @@ impl Dialog {
|
||||||
ui,
|
ui,
|
||||||
|_ui| {},
|
|_ui| {},
|
||||||
|ui| {
|
|ui| {
|
||||||
if ui.button("Ok").clicked() {
|
if ui.button("Ok").clicked() ||
|
||||||
|
ui.input(|i| i.key_pressed(egui::Key::Enter))
|
||||||
|
{
|
||||||
is_open = false;
|
is_open = false;
|
||||||
if let Err(e) =
|
if let Err(e) =
|
||||||
response_sender.send(PromptResponse::Ok(input.clone()))
|
response_sender.send(PromptResponse::Ok(input.clone()))
|
||||||
|
@ -214,7 +222,9 @@ impl Dialog {
|
||||||
warn!("Failed to send input dialog response: {}", e);
|
warn!("Failed to send input dialog response: {}", e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ui.button("Cancel").clicked() {
|
if ui.button("Cancel").clicked() ||
|
||||||
|
ui.input(|i| i.key_pressed(egui::Key::Escape))
|
||||||
|
{
|
||||||
is_open = false;
|
is_open = false;
|
||||||
if let Err(e) = response_sender.send(PromptResponse::Cancel) {
|
if let Err(e) = response_sender.send(PromptResponse::Cancel) {
|
||||||
warn!("Failed to send input dialog response: {}", e);
|
warn!("Failed to send input dialog response: {}", e);
|
||||||
|
@ -263,13 +273,17 @@ impl Dialog {
|
||||||
ui,
|
ui,
|
||||||
|_ui| {},
|
|_ui| {},
|
||||||
|ui| {
|
|ui| {
|
||||||
if ui.button("Sign in").clicked() {
|
if ui.button("Sign in").clicked() ||
|
||||||
|
ui.input(|i| i.key_pressed(egui::Key::Enter))
|
||||||
|
{
|
||||||
let request =
|
let request =
|
||||||
request.take().expect("non-None until dialog is closed");
|
request.take().expect("non-None until dialog is closed");
|
||||||
request.authenticate(username.clone(), password.clone());
|
request.authenticate(username.clone(), password.clone());
|
||||||
is_open = false;
|
is_open = false;
|
||||||
}
|
}
|
||||||
if ui.button("Cancel").clicked() {
|
if ui.button("Cancel").clicked() ||
|
||||||
|
ui.input(|i| i.key_pressed(egui::Key::Escape))
|
||||||
|
{
|
||||||
is_open = false;
|
is_open = false;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
@ -286,13 +300,17 @@ impl Dialog {
|
||||||
ui,
|
ui,
|
||||||
|_ui| {},
|
|_ui| {},
|
||||||
|ui| {
|
|ui| {
|
||||||
if ui.button("Allow").clicked() {
|
if ui.button("Allow").clicked() ||
|
||||||
|
ui.input(|i| i.key_pressed(egui::Key::Enter))
|
||||||
|
{
|
||||||
let request =
|
let request =
|
||||||
request.take().expect("non-None until dialog is closed");
|
request.take().expect("non-None until dialog is closed");
|
||||||
request.allow();
|
request.allow();
|
||||||
is_open = false;
|
is_open = false;
|
||||||
}
|
}
|
||||||
if ui.button("Deny").clicked() {
|
if ui.button("Deny").clicked() ||
|
||||||
|
ui.input(|i| i.key_pressed(egui::Key::Escape))
|
||||||
|
{
|
||||||
let request =
|
let request =
|
||||||
request.take().expect("non-None until dialog is closed");
|
request.take().expect("non-None until dialog is closed");
|
||||||
request.deny();
|
request.deny();
|
||||||
|
@ -332,7 +350,9 @@ impl Dialog {
|
||||||
ui,
|
ui,
|
||||||
|_ui| {},
|
|_ui| {},
|
||||||
|ui| {
|
|ui| {
|
||||||
if ui.button("Ok").clicked() {
|
if ui.button("Ok").clicked() ||
|
||||||
|
ui.input(|i| i.key_pressed(egui::Key::Enter))
|
||||||
|
{
|
||||||
if let Err(e) = response_sender
|
if let Err(e) = response_sender
|
||||||
.send(Some(devices[*selected_device_index].clone()))
|
.send(Some(devices[*selected_device_index].clone()))
|
||||||
{
|
{
|
||||||
|
@ -340,7 +360,9 @@ impl Dialog {
|
||||||
}
|
}
|
||||||
is_open = false;
|
is_open = false;
|
||||||
}
|
}
|
||||||
if ui.button("Cancel").clicked() {
|
if ui.button("Cancel").clicked() ||
|
||||||
|
ui.input(|i| i.key_pressed(egui::Key::Escape))
|
||||||
|
{
|
||||||
if let Err(e) = response_sender.send(None) {
|
if let Err(e) = response_sender.send(None) {
|
||||||
warn!("Failed to send cancellation: {}", e);
|
warn!("Failed to send cancellation: {}", e);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue