-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
Keyboard shortcut helpers #2202
Merged
Merged
Conversation
This file contains 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.
This adds
egui::KeyboardShortcut
which isModifiers
+Key
.You can check it with
input.consume_shortcut
.You can format it to text using
Context::format_shortcut
.You can set that text on buttons (e.g. for menus) with
Button::shortcut_text
.If you use
Modifiers::COMMAND
, egui will check it against the Mac Command key (⌘) on Mac, but check against Ctrl on other platforms. This means how the shortcut is formatted depends on the OS you are running on. This is difficult to know when compiling forwasm32
, soegui
now also hasContext::set_os
andContext::os
to set/get that.set_os
is meant for egui integrartions.eframe
will guess the OS from theUser-Agent
string when on web. On native it will usetarget_os
.Bonus 1: You can now ask
eframe
about theUser-Agent
string when on web usingframe.info().web_info.user_agent
.Bonus 2: You can now query if epaint/egui can show some characters by using
Fonts::has_glyph(s)
.TODO: