Skip to content

Commit

Permalink
Merge pull request #1639 from giduac/1373-Getting-an-application-cras…
Browse files Browse the repository at this point in the history
…h-when-pressing-the-Delete-key

1373-Getting-an-application-crash-when-pressing-the-Delete-key
  • Loading branch information
Smurf-IV authored Jul 17, 2024
2 parents d8843a2 + 3dc9fb9 commit eb8fdc4
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 3 deletions.
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

0 comments on commit eb8fdc4

Please sign in to comment.