mirror of
https://github.com/emilk/egui.git
synced 2026-08-30 05:10:03 -04:00
Force canvas/text input focus on touch for iOS web browsers (#4848)
This commit is contained in:
@@ -5,7 +5,7 @@ use std::cell::Cell;
|
||||
|
||||
use wasm_bindgen::prelude::*;
|
||||
|
||||
use super::{AppRunner, WebRunner};
|
||||
use super::{is_mobile, AppRunner, WebRunner};
|
||||
|
||||
pub struct TextAgent {
|
||||
input: web_sys::HtmlInputElement,
|
||||
@@ -173,16 +173,3 @@ impl Drop for TextAgent {
|
||||
self.input.remove();
|
||||
}
|
||||
}
|
||||
|
||||
/// Returns `true` if the app is likely running on a mobile device.
|
||||
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