This commit is contained in:
Simon Gardling
2022-04-23 15:58:40 -04:00
parent 3db239a582
commit 3f323e72a1
5 changed files with 18 additions and 7 deletions

View File

@@ -74,7 +74,8 @@ pub const COLORS: &[Color32; 13] = &[
#[cfg(target_arch = "wasm32")]
lazy_static::lazy_static! {
pub static IS_MOBILE: bool = {
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"];
@@ -83,8 +84,17 @@ lazy_static::lazy_static! {
}
is_mobile().unwrap_or_default()
}
};
}
#[cfg(not(target_arch = "wasm32"))]
pub const IS_MOBILE: bool = false;
const IS_MOBILE: bool = false;
#[inline]
pub fn is_mobile() -> bool {
#[cfg(target_arch = "wasm32")]
return *IS_MOBILE;
#[cfg(not(target_arch = "wasm32"))]
return IS_MOBILE;
}

View File

@@ -1,4 +1,4 @@
use crate::consts::IS_MOBILE;
use crate::consts::is_mobile;
use crate::function_entry::{FunctionEntry, DEFAULT_FUNCTION_ENTRY};
use crate::widgets::{move_cursor_to_end, widgets_ontop, Movement};
use egui::{Button, Key, Modifiers};
@@ -76,7 +76,7 @@ impl Manager {
function.autocomplete.update_string(&new_string);
if !function.autocomplete.hint.is_none() {
if !IS_MOBILE && !function.autocomplete.hint.is_single() {
if !is_mobile() && !function.autocomplete.hint.is_single() {
if ui.input().key_pressed(Key::ArrowDown) {
movement = Movement::Down;
} else if ui.input().key_pressed(Key::ArrowUp) {