Skip to content

Comments

Fix: Windows submenu icons support#308

Merged
amrbashir merged 7 commits intotauri-apps:devfrom
s00d:dev
Jul 28, 2025
Merged

Fix: Windows submenu icons support#308
amrbashir merged 7 commits intotauri-apps:devfrom
s00d:dev

Conversation

@s00d
Copy link
Contributor

@s00d s00d commented Jul 25, 2025

Description

This PR is a follow-up to PR #277 which added submenu icon support across all platforms. While the initial implementation worked on macOS and Linux, I discovered that submenu icons were not displaying correctly on Windows due to incorrect ID handling.

Problem

On Windows, submenu icons were not displaying correctly. The issue was that the Windows API requires different handling for submenu icons compared to regular menu items.

Root Cause

In src/platform_impl/windows/mod.rs, the code was using the same ID (internal_id) for both regular menu items and submenus when setting icons:

SetMenuItemInfoW(self.hmenu, child_.internal_id(), FALSE, &info);

However, Windows API requires different IDs for submenus (hmenu) vs regular menu items (internal_id).

Solution

Modified the icon setting logic to use the correct ID based on the menu item type:

  1. For regular menu items: Use internal_id as before
  2. For submenus: Use hmenu as the ID

Updated both the initial icon setting in add_menu_item and the dynamic icon setting in set_icon method.

Changes Made

  1. src/platform_impl/windows/mod.rs:

    • Modified icon setting logic to use correct IDs for submenus vs regular items
    • Updated both add_menu_item and set_icon methods
    • Added proper handling for submenu icon creation
  2. Examples:

    • Added submenu icon examples in examples/test_submenu_icons.rs
    • Updated existing examples to demonstrate submenu icon functionality

Testing

  • Tested on Windows with submenu icons
  • Verified that both text and icons display correctly
  • Confirmed compatibility with existing functionality
  • Added example demonstrating submenu icon usage

@s00d
Copy link
Contributor Author

s00d commented Jul 25, 2025

@amrbashir please review these changes, as submenu icons won't work on Windows without these fixes

Copy link
Member

@amrbashir amrbashir left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you, could you also add a change file in .changes directory?

@s00d
Copy link
Contributor Author

s00d commented Jul 27, 2025

@amrbashir Hi, sorry — I missed internal_id() earlier. After updating it, everything started working. I've fixed it and also added the change_file.

Copy link
Member

@amrbashir amrbashir left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you

@amrbashir amrbashir merged commit 0ae81ad into tauri-apps:dev Jul 28, 2025
10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants