feat: app.with_on_start() function#1783
Open
l0uisgrange wants to merge 1 commit intolinebender:mainfrom
Open
Conversation
l0uisgrange
commented
May 1, 2026
| // Font data to include in loading. | ||
| fonts: Vec<Blob<u8>>, | ||
| // Callback invoked once on startup, after windows creation. | ||
| on_start: Option<Box<dyn FnOnce(&mut MasonryState<'_>)>>, |
Contributor
Author
There was a problem hiding this comment.
I do not need the MasonryState argument for the use cases I introduced, but maybe someone needs it one day? I can remove it if you think it's unnecessary.
Contributor
|
Have you tried https://github.com/baltobor/xilem_extras ? It claims to provide application menus using |
Contributor
Author
|
Yes, I've found the library in a comment a few days ago and tried it. It is good, indeed, though I would love to bring some of its components to |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
A new function
.with_on_start()is introduced onXilem::newto run aFnOnceafter the app has started.This has a few use cases, and amongst them:
Check for update on startup (with some API/GitHub releases/etc.)
More specific for macOS, but this allows compatibility with the
mudacrate. Without this, it's almost impossible to add items in the macOS menu bar (used by all applications), becauseNSApplicationneeds to be set before usingmudafunctions, which is only possible after the initialization ofXilemIf you're not familiar with macOS, the menu bar looks like this