mirror of
https://github.com/emilk/egui.git
synced 2026-08-29 12:50:04 -04:00
Force canvas/text input focus on touch for iOS web browsers (#4848)
This commit is contained in:
@@ -264,3 +264,16 @@ pub fn percent_decode(s: &str) -> String {
|
||||
.decode_utf8_lossy()
|
||||
.to_string()
|
||||
}
|
||||
|
||||
/// Returns `true` if the app is likely running on a mobile device.
|
||||
pub(crate) fn is_mobile() -> bool {
|
||||
fn try_is_mobile() -> Option<bool> {
|
||||
const MOBILE_DEVICE: [&str; 6] =
|
||||
["Android", "iPhone", "iPad", "iPod", "webOS", "BlackBerry"];
|
||||
|
||||
let user_agent = web_sys::window()?.navigator().user_agent().ok()?;
|
||||
let is_mobile = MOBILE_DEVICE.iter().any(|&name| user_agent.contains(name));
|
||||
Some(is_mobile)
|
||||
}
|
||||
try_is_mobile().unwrap_or(false)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user