Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Set focus to context menu to allow using esc when not focused #119

Merged
merged 1 commit into from
Oct 7, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion src/NotifyIconWpf/TaskbarIcon.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// hardcodet.net NotifyIcon for WPF
// hardcodet.net NotifyIcon for WPF
// Copyright (c) 2009 - 2022 Philipp Sumi. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
// Contact and Information: http://www.hardcodet.net
Expand Down Expand Up @@ -783,6 +783,9 @@ private void ShowContextMenu(Point cursorPosition)
// fallback, the context menu can't receive keyboard events - should not happen though
WinApi.SetForegroundWindow(handle);

// set also the focus to the context menu, so that the keyboard works (using ESC if mouse is not over context menu).
ContextMenu.Focus();

// bubble event
RaiseTrayContextMenuOpenEvent();
}
Expand Down