cleanup
This commit is contained in:
@@ -50,25 +50,3 @@ pub const COLORS: [Color32; 13] = [
|
||||
];
|
||||
|
||||
const_assert!(!COLORS.is_empty());
|
||||
|
||||
#[cfg(target_arch = "wasm32")]
|
||||
lazy_static::lazy_static! {
|
||||
static ref IS_MOBILE: bool = {
|
||||
// from https://github.com/emilk/egui/blob/fda8189cbab18e0acab8db972400e4a4ca0d915e/egui_web/src/text_agent.rs#L194
|
||||
fn 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()?;
|
||||
Some(MOBILE_DEVICE.iter().any(|&name| user_agent.contains(name)))
|
||||
}
|
||||
|
||||
is_mobile().unwrap_or_default()
|
||||
};
|
||||
}
|
||||
|
||||
#[inline]
|
||||
#[cfg(target_arch = "wasm32")]
|
||||
pub fn is_mobile() -> bool { return *IS_MOBILE; }
|
||||
|
||||
#[cfg(not(target_arch = "wasm32"))]
|
||||
pub const fn is_mobile() -> bool { false }
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
use crate::consts::is_mobile;
|
||||
use crate::function_entry::FunctionEntry;
|
||||
use crate::misc::random_u64;
|
||||
use crate::widgets::widgets_ontop;
|
||||
@@ -109,7 +108,7 @@ impl FunctionManager {
|
||||
function.autocomplete.update_string(&new_string);
|
||||
|
||||
if function.autocomplete.hint.is_some() {
|
||||
if !function.autocomplete.hint.is_single() && !is_mobile() {
|
||||
if !function.autocomplete.hint.is_single() {
|
||||
if ui.input().key_pressed(Key::ArrowDown) {
|
||||
movement = Movement::Down;
|
||||
} else if ui.input().key_pressed(Key::ArrowUp) {
|
||||
@@ -118,11 +117,7 @@ impl FunctionManager {
|
||||
}
|
||||
|
||||
// Put here so these key presses don't interact with other elements
|
||||
let enter_pressed = match is_mobile() {
|
||||
true => false,
|
||||
false => ui.input_mut().consume_key(Modifiers::NONE, Key::Enter),
|
||||
};
|
||||
|
||||
let enter_pressed = ui.input_mut().consume_key(Modifiers::NONE, Key::Enter);
|
||||
let tab_pressed = ui.input_mut().consume_key(Modifiers::NONE, Key::Tab);
|
||||
if enter_pressed | tab_pressed | ui.input().key_pressed(Key::ArrowRight) {
|
||||
movement = Movement::Complete;
|
||||
|
||||
Reference in New Issue
Block a user