slint
slint copied to clipboard
fix: disable default menu to allow custom menus
Slint at the moment does not support native menu bar integration. This PR aims to alleviate this issue somewhat by making slint compatible with the muda crate from tauri.
Muda does not work when the default menu for the menu-bar is enabled, thus this PR disables it by default on MacOS.
Thanks for the patch. I'm a little torn about this :-)
On the one hand, I think it's in everyone's interest to be able to use Slint with muda. Yes, to that.
On the other hand, when not using muda, this makes a suboptimal situation even worse: By default, winit adds a minimal entry to the system menubar on macOS with an about item and the ability to quick the application. With this change and when not using muda, there's no more system menubar - instead the menubar of the previous application is active. I think that's very confusing.
I think that perhaps the use-case of muda is best addressed by using the window_builder_hook. What do you think?
Thanks for taking a look @tronical. I agree with you here, if you don't supply a custom menu-bar then the experience becomes suboptimal. I think ideally we'd need a event_loop_builder_hook, as the menu-bar isnt controlled via the WindowBuilder but rather the EventLoopBuilder.
Let me know what you think! Also on another note, adding a event_loop_builder_hook would also allow us to create a proxy for the EventLoop that would be exposed publicly, I and many others have use-cases where we need access to the raw event-loop event stream. We could potentially kill two birds with a single stone here!
Oops, good catch about EventLoopBuilder vs. WindowBuilder. Since there can only ever be one EventLoop and that's created in new_with_renderer_by_name, I think a hook wouldn't work but it would have to be a parameter to the new function. Maybe like new_with_event_loop_builder?
So we'd pass a event-loop builder? Why not just pass a built event-loop?
that sounds okay to me :)
We have a builder now in the master branch in the private API: https://snapshots.slint.dev/master/docs/rust/i_slint_backend_winit/struct.backendbuilder#method.with_event_loop_builder
I guess that the proper fix would be to add direct support for menu (tracked in issue #38) And in the mean time one would need to use the private API. I'm going to close this PR. But still, thanks a lot for the contribution!