mirror of
https://github.com/emilk/egui.git
synced 2026-06-27 23:13:13 -04:00
Keyboard shortcut helpers (#2202)
* eframe web: Add WebInfo::user_agent * Deprecate `Modifier::ALT_SHIFT` * Add code for formatting Modifiers and Key * Add type KeyboardShortcut * Code cleanup * Add Context::os/set_os to query/set what OS egui believes it is on * Add Fonts::has_glyph(s) * Add helper function for formatting keyboard shortcuts * Faster code * Add way to set a shortcut text on menu buttons * Cleanup * format_keyboard_shortcut -> format_shortcut * Add TODO about supporting more keyboard sumbols * Modifiers::plus * Use the new keyboard shortcuts in emark editor demo * Explain why ALT+SHIFT is a bad modifier combo * Fix doctest
This commit is contained in:
@@ -87,6 +87,10 @@ impl IsDestroyed {
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
fn user_agent() -> Option<String> {
|
||||
web_sys::window()?.navigator().user_agent().ok()
|
||||
}
|
||||
|
||||
fn web_location() -> epi::Location {
|
||||
let location = web_sys::window().unwrap().location();
|
||||
|
||||
@@ -198,6 +202,7 @@ impl AppRunner {
|
||||
|
||||
let info = epi::IntegrationInfo {
|
||||
web_info: epi::WebInfo {
|
||||
user_agent: user_agent().unwrap_or_default(),
|
||||
location: web_location(),
|
||||
},
|
||||
system_theme,
|
||||
@@ -207,6 +212,9 @@ impl AppRunner {
|
||||
let storage = LocalStorage::default();
|
||||
|
||||
let egui_ctx = egui::Context::default();
|
||||
egui_ctx.set_os(egui::os::OperatingSystem::from_user_agent(
|
||||
&user_agent().unwrap_or_default(),
|
||||
));
|
||||
load_memory(&egui_ctx);
|
||||
|
||||
let theme = system_theme.unwrap_or(web_options.default_theme);
|
||||
|
||||
Reference in New Issue
Block a user