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

1373-Getting-an-application-crash-when-pressing-the-Delete-key #1639

Merged
Show file tree
Hide file tree
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
1 change: 1 addition & 0 deletions Documents/Changelog/Changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,7 @@
=======

## 2024-07-xx - Build 2407 (Version 85 - Patch 1) - July 2024
* Resolved [#1373](https://github.com/Krypton-Suite/Standard-Toolkit/issues/1373), `KT.CommonHelper.CheckContextMenuForShortcut()` handles direct type casts differently from .NET 8.0 onward. Solution courtesy of @Tape-Worm
* Resolved [#1583](https://github.com/Krypton-Suite/Standard-Toolkit/issues/1583), `KryptonThemeComboBox` and `KrpytonThemeListBox` have the wrong designer assigned. Adds the `KryptonStubDesigner` internal class.
* Resolved [#1614](https://github.com/Krypton-Suite/Standard-Toolkit/issues/1614), `KryptonMessageBox` throws an exception after Esc key is pressed.
* Resolved [#1613](https://github.com/Krypton-Suite/Standard-Toolkit/issues/1613), `KryptonMessageBox` text is not centered vertically.
Expand Down
25 changes: 22 additions & 3 deletions Source/Krypton Components/Krypton.Toolkit/General/CommonHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -150,13 +150,32 @@ public static bool CheckContextMenuForShortcut(ContextMenuStrip? cms,
}

// Get any menu item from context strip that matches the shortcut key combination
var shortcuts = _cachedShortcutPI!.GetValue(cms, null) as Hashtable;
Hashtable? hashTableShortCuts = _cachedShortcutPI!.GetValue(cms, null) as Hashtable;
ToolStripMenuItem? menuItem = null;

if (hashTableShortCuts is null)
{
Dictionary<Keys, ToolStripMenuItem>? dictionaryShortcuts = _cachedShortcutPI!.GetValue(cms, null) as Dictionary<Keys, ToolStripMenuItem>;

if (dictionaryShortcuts is not null)
{
dictionaryShortcuts.TryGetValue(keyData, out menuItem);
}
else
{
return false;
}
}
else
{
menuItem = hashTableShortCuts[keyData] as ToolStripMenuItem;
}

// If we found a match...
if (shortcuts![keyData] is ToolStripMenuItem menuItem)
if (menuItem is not null)
{
// Get the menu item to process the shortcut
var ret = _cachedShortcutMI!.Invoke(menuItem, [msg, keyData]);
var ret = _cachedShortcutMI!.Invoke(menuItem, new object[] { msg, keyData });

// Return the 'ProcessCmdKey' result
if (ret != null)
Expand Down