mirror of
https://github.com/microsoft/edit.git
synced 2026-06-13 12:02:16 -05:00
Fix consume_shortcut calls not checking for focus (#298)
This commit is contained in:
@@ -227,6 +227,8 @@ pub fn draw_handle_wants_close(ctx: &mut Context, state: &mut State) {
|
||||
ctx.attr_background_rgba(ctx.indexed(IndexedColor::Red));
|
||||
ctx.attr_foreground_rgba(ctx.indexed(IndexedColor::BrightWhite));
|
||||
{
|
||||
let contains_focus = ctx.contains_focus();
|
||||
|
||||
ctx.label("description", loc(LocId::UnsavedChangesDialogDescription));
|
||||
ctx.attr_padding(Rect::three(1, 2, 1));
|
||||
|
||||
@@ -259,10 +261,12 @@ pub fn draw_handle_wants_close(ctx: &mut Context, state: &mut State) {
|
||||
}
|
||||
|
||||
// Handle accelerator shortcuts
|
||||
if ctx.consume_shortcut(vk::S) {
|
||||
action = Action::Save;
|
||||
} else if ctx.consume_shortcut(vk::N) {
|
||||
action = Action::Discard;
|
||||
if contains_focus {
|
||||
if ctx.consume_shortcut(vk::S) {
|
||||
action = Action::Save;
|
||||
} else if ctx.consume_shortcut(vk::N) {
|
||||
action = Action::Discard;
|
||||
}
|
||||
}
|
||||
}
|
||||
ctx.table_end();
|
||||
|
||||
@@ -131,6 +131,8 @@ pub fn draw_file_picker(ctx: &mut Context, state: &mut State) {
|
||||
ctx.attr_background_rgba(ctx.indexed(IndexedColor::Red));
|
||||
ctx.attr_foreground_rgba(ctx.indexed(IndexedColor::BrightWhite));
|
||||
{
|
||||
let contains_focus = ctx.contains_focus();
|
||||
|
||||
ctx.label("description", loc(LocId::FileOverwriteWarningDescription));
|
||||
ctx.attr_overflow(Overflow::TruncateTail);
|
||||
ctx.attr_padding(Rect::three(1, 2, 1));
|
||||
@@ -153,9 +155,11 @@ pub fn draw_file_picker(ctx: &mut Context, state: &mut State) {
|
||||
}
|
||||
ctx.table_end();
|
||||
|
||||
save |= ctx.consume_shortcut(vk::Y);
|
||||
if ctx.consume_shortcut(vk::N) {
|
||||
state.file_picker_overwrite_warning = None;
|
||||
if contains_focus {
|
||||
save |= ctx.consume_shortcut(vk::Y);
|
||||
if ctx.consume_shortcut(vk::N) {
|
||||
state.file_picker_overwrite_warning = None;
|
||||
}
|
||||
}
|
||||
}
|
||||
if ctx.modal_end() {
|
||||
|
||||
@@ -95,7 +95,7 @@ pub fn draw_statusbar(ctx: &mut Context, state: &mut State) {
|
||||
ctx.attr_padding(Rect::two(0, 1));
|
||||
ctx.table_set_cell_gap(Size { width: 1, height: 0 });
|
||||
{
|
||||
if ctx.consume_shortcut(vk::RETURN) {
|
||||
if ctx.contains_focus() && ctx.consume_shortcut(vk::RETURN) {
|
||||
ctx.toss_focus_up();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user