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

2
Cargo.lock generated
View File

@ -679,8 +679,10 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9be70c98951c83b8d2f8f60d7065fa6d5146873094452a1008da8c2f1e4205ad"
dependencies = [
"cfg-if 1.0.0",
"js-sys",
"libc",
"wasi 0.10.2+wasi-snapshot-preview1",
"wasm-bindgen",
]
[[package]]

View File

@ -47,7 +47,7 @@ tracing = "0.1.34"
itertools = "0.10.3"
static_assertions = "1.1.0"
phf = "0.10.1"
uuid = { version = "1.0.0", features = ["v4", "fast-rng"] }
uuid = { version = "1.0.0", features = ["v4", "fast-rng", "js"] }
[build-dependencies]

View File

@ -2,7 +2,6 @@
1. Function management
- Integrals between functions (too hard to implement, maybe will shelve)
- Display intersection between functions (would have to rewrite a lot of the function plotting handling)
- Sort by UUIDs
- [Drag and drop support](https://github.com/emilk/egui/discussions/1530) in the UI
- Hide/disable functions
- Prevent user from making too many function entries

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) {