mirror of
https://github.com/Tichau/FileConverter.git
synced 2026-11-20 09:32:54 +01:00
Fix: Nested presets failing with 17+ files due to menu collision
On the current upstream branch, converting 17+ files at once revealed an underlying issue where the program wouldn't necessarily choose the correct conversion profile. After 16 files are selected, Windows Explorer seems to optimize the context menu such that multiple `ToolStripMenuItems` with identical `text` properties share the same callback, which causes ambiguity issues. As a workaround, each menu's `text` property has a unique number of zero-width characters appended to it. This makes the text technically unique, ensuring that Windows maintains the distinction. Furthermore, it preserves the UI, has a minimal code refactor, and resolves an issue that has been reported at least twice and likely impacts all instances of FileConverter. Fixes #614, #567
This commit is contained in:
1 parent
892c8cbcef
commit
02e5b5bad7
1 file changed
+9
-1
@@ -104,8 +104,11 @@ namespace FileConverterExtension
|
||||
Image = new Icon(Properties.Resources.ApplicationIcon, SystemInformation.SmallIconSize).ToBitmap(),
|
||||
};
|
||||
|
||||
int menuItemIndex = 0;
|
||||
foreach (MenuEntry menuEntry in this.menuEntries)
|
||||
{
|
||||
menuItemIndex++;
|
||||
|
||||
ToolStripMenuItem root = fileConverterItem;
|
||||
if (menuEntry.PresetReference.Folders != null)
|
||||
{
|
||||
@@ -142,9 +145,14 @@ namespace FileConverterExtension
|
||||
root = fileConverterItem;
|
||||
}
|
||||
|
||||
// Make each menu item text unique using invisible zero-width spaces
|
||||
// This prevents Windows Forms menu collision while being completely invisible to users
|
||||
string uniqueSuffix = new string('\u200B', menuItemIndex); // Zero-Width Space characters
|
||||
string displayText = menuEntry.PresetReference.Name + uniqueSuffix;
|
||||
|
||||
ToolStripMenuItem subItem = new ToolStripMenuItem
|
||||
{
|
||||
Text = menuEntry.PresetReference.Name,
|
||||
Text = displayText,
|
||||
Enabled = menuEntry.Enabled
|
||||
};
|
||||
|
||||
|
||||
Reference in new issue
Block a user