-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
feat(windows): Add DisableMenu option to WindowsWindow #4813
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
base: v3-alpha
Are you sure you want to change the base?
Conversation
Fixed GitHub Issue wailsapp#4273 - Added the missing `DisableMenu` property to the `WindowsWindow` struct in Wails v3. ### Changes Made: 1. **`webview_window_options.go:284-286`** - Added `DisableMenu bool` property to the `WindowsWindow` struct with documentation: ```go // DisableMenu will disable the menu for the window. // Default: false DisableMenu bool ``` 2. **`webview_window_windows.go:87-89`** - Updated `setMenu()` to respect `DisableMenu` by returning early if disabled 3. **`webview_window_windows.go:362`** - Updated window creation to not process menu when `DisableMenu` is true: ```go if !options.Frameless && !options.Windows.DisableMenu { ``` 4. **`webview_window_windows.go:2342-2344`** - Updated `toggleMenuBar()` to respect `DisableMenu` 5. **`webview_window_windows.go:2457-2459`** - Updated `showMenuBar()` to respect `DisableMenu` ### Usage: ```go app.NewWebviewWindowWithOptions(application.WebviewWindowOptions{ Windows: application.WindowsWindow{ DisableMenu: true, }, }) ``` This follows the same pattern as other `Disable*` properties like `DisableIcon` and `DisableFramelessWindowDecorations`.
## Summary ### Code Changes 1. **`v3/pkg/application/webview_window_options.go:284-286`** - Added `DisableMenu` property to `WindowsWindow` struct: ```go // DisableMenu will disable the menu for the window. // Default: false DisableMenu bool ``` 2. **`v3/pkg/application/webview_window_windows.go:87-89`** - Updated `setMenu()` to return early if `DisableMenu` is true 3. **`v3/pkg/application/webview_window_windows.go:362`** - Updated window creation to skip menu processing when `DisableMenu` is true 4. **`v3/pkg/application/webview_window_windows.go:2342-2344`** - Updated `toggleMenuBar()` to respect `DisableMenu` 5. **`v3/pkg/application/webview_window_windows.go:2457-2459`** - Updated `showMenuBar()` to respect `DisableMenu` ### Documentation Changes 1. **`v3/UNRELEASED_CHANGELOG.md`** - Added entry: ``` - Add `DisableMenu` option to `WindowsWindow` to disable the menu bar on Windows (wailsapp#4273) ``` 2. **`docs/src/content/docs/features/windows/options.mdx`** - Updated Windows Options section to include `DisableMenu` with documentation and examples
|
Warning Rate limit exceeded@leaanthony has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 25 minutes and 18 seconds before requesting another review. ⌛ How to resolve this issue?After the wait time has elapsed, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout. Please see our FAQ for further information. 📒 Files selected for processing (2)
WalkthroughThis pull request adds a new Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes
Possibly related PRs
Suggested labels
Poem
Pre-merge checks and finishing touches✅ Passed checks (5 passed)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
🧹 Nitpick comments (1)
v3/pkg/application/webview_window_windows.go (1)
2465-2469: Consider adding a DisableMenu guard for consistency.While the current implementation is functionally correct (since
w.menuwould benilwhenDisableMenuis true), adding an explicit early-return guard like the other menu functions (setMenu,toggleMenuBar,showMenuBar) would improve consistency and code clarity.func (w *windowsWebviewWindow) hideMenuBar() { + if w.parent.options.Windows.DisableMenu { + return + } if w.menu != nil { w32.SetMenu(w.hwnd, 0) } }
📜 Review details
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (4)
docs/src/content/docs/features/windows/options.mdx(3 hunks)v3/UNRELEASED_CHANGELOG.md(1 hunks)v3/pkg/application/webview_window_options.go(1 hunks)v3/pkg/application/webview_window_windows.go(4 hunks)
🧰 Additional context used
🧠 Learnings (3)
📚 Learning: 2024-09-20T23:34:29.841Z
Learnt from: nixpare
Repo: wailsapp/wails PR: 3763
File: v3/examples/keybindings/main.go:16-17
Timestamp: 2024-09-20T23:34:29.841Z
Learning: In the codebase, `application.Options.KeyBindings` uses the `application.Window` type, whereas `application.WebviewWindowOptions.KeyBindings` uses `*application.WebviewWindow`. This is intentional and acceptable.
Applied to files:
v3/pkg/application/webview_window_options.gov3/pkg/application/webview_window_windows.go
📚 Learning: 2025-01-24T22:41:18.566Z
Learnt from: leaanthony
Repo: wailsapp/wails PR: 4031
File: v3/pkg/application/menu.go:199-202
Timestamp: 2025-01-24T22:41:18.566Z
Learning: In the Wails menu system (v3/pkg/application/menu.go), shared state between menus is intentionally designed and desirable. Methods like `Append()` and `Prepend()` should maintain shared references to menu items rather than creating deep copies.
Applied to files:
v3/pkg/application/webview_window_windows.go
📚 Learning: 2025-10-17T23:16:11.570Z
Learnt from: Sammy-T
Repo: wailsapp/wails PR: 4570
File: v2/internal/frontend/desktop/linux/window_webkit6.go:97-108
Timestamp: 2025-10-17T23:16:11.570Z
Learning: For webkit_6/GTK4 builds in v2/internal/frontend/desktop/linux/window_webkit6.go, GTK widget creation should not be wrapped in invokeOnMainThread. The activation mechanism (activateWg + onActivate export) already handles thread safety, and additional wrapping would cause issues.
Applied to files:
v3/pkg/application/webview_window_windows.go
🔇 Additional comments (7)
v3/UNRELEASED_CHANGELOG.md (1)
20-20: LGTM!The changelog entry clearly documents the new feature and references the related issue.
v3/pkg/application/webview_window_options.go (1)
284-286: LGTM!The new
DisableMenufield follows the established pattern used byDisableIconandDisableFramelessWindowDecorations. The placement after theMenufield is logical, and the documentation clearly explains its purpose and default value.docs/src/content/docs/features/windows/options.mdx (1)
699-699: LGTM!The documentation is clear, comprehensive, and consistent with the existing pattern. The explanation correctly describes that the menu bar will not display even if one is configured when
DisableMenuis true. The examples demonstrate proper usage.Also applies to: 710-713, 835-835
v3/pkg/application/webview_window_windows.go (4)
87-89: LGTM!The early return guard correctly prevents menu setup when
DisableMenuis true. This ensures that even ifsetMenu()is called programmatically, it has no effect when the option is disabled.
362-369: LGTM!The condition correctly ensures that the menu is only created during window initialization when both
Framelessis false ANDDisableMenuis false. This is the primary gate that prevents menu creation when the option is disabled.
2342-2344: LGTM!The guard correctly prevents menu bar toggling when
DisableMenuis true, ensuring the test plan requirement is met.
2457-2459: LGTM!The guard correctly prevents showing the menu bar when
DisableMenuis true, ensuring the test plan requirement is met.
|




Summary
DisableMenuproperty toWindowsWindowstruct to allow disabling the menu bar on WindowsDisableMenuistrue, the window will not display a menu bar even if one is configuredDisableIconandDisableFramelessWindowDecorationspropertiesFixes #4273
Test plan
Windows.DisableMenu: trueand verify no menu bar appearsWindows.DisableMenu: false(or omitted) and verify menu bar works normallySetMenu()at runtime withDisableMenu: trueand verify it has no effecttoggleMenuBar()andshowMenuBar()withDisableMenu: trueand verify they have no effect🤖 Generated with Claude Code
Summary by CodeRabbit
DisableMenuoption for Windows applications. When enabled, the menu bar is hidden regardless of menu configuration. This option defaults to false, preserving existing behavior and allowing developers to optionally hide the menu bar.✏️ Tip: You can customize this high-level summary in your review settings.