mirror of
https://github.com/emilk/egui.git
synced 2026-08-30 13:20:05 -04:00
Remove the need for setting web_sys_unstable_apis (#5000)
* No longer required since https://github.com/emilk/egui/pull/4980 And despite some outdated comments, wgpu/WebGPU doesn't need it either
This commit is contained in:
@@ -10,9 +10,6 @@
|
||||
//! call [`crate::run_native`] from your `main.rs`, and/or use `eframe::WebRunner` from your `lib.rs`.
|
||||
//!
|
||||
//! ## Compiling for web
|
||||
//! To get copy-paste working on web, you need to compile with
|
||||
//! `export RUSTFLAGS=--cfg=web_sys_unstable_apis`.
|
||||
//!
|
||||
//! You need to install the `wasm32` target with `rustup target add wasm32-unknown-unknown`.
|
||||
//!
|
||||
//! Build the `.wasm` using `cargo build --target wasm32-unknown-unknown`
|
||||
|
||||
@@ -276,14 +276,10 @@ impl AppRunner {
|
||||
super::open_url(&open.url, open.new_tab);
|
||||
}
|
||||
|
||||
#[cfg(web_sys_unstable_apis)]
|
||||
if !copied_text.is_empty() {
|
||||
super::set_clipboard_text(&copied_text);
|
||||
}
|
||||
|
||||
#[cfg(not(web_sys_unstable_apis))]
|
||||
let _ = copied_text;
|
||||
|
||||
if self.has_focus() {
|
||||
// The eframe app has focus.
|
||||
if ime.is_some() {
|
||||
|
||||
@@ -279,7 +279,6 @@ pub(crate) fn on_keyup(event: web_sys::KeyboardEvent, runner: &mut AppRunner) {
|
||||
}
|
||||
|
||||
fn install_copy_cut_paste(runner_ref: &WebRunner, target: &EventTarget) -> Result<(), JsValue> {
|
||||
#[cfg(web_sys_unstable_apis)]
|
||||
runner_ref.add_event_listener(target, "paste", |event: web_sys::ClipboardEvent, runner| {
|
||||
if let Some(data) = event.clipboard_data() {
|
||||
if let Ok(text) = data.get_data("text") {
|
||||
@@ -294,7 +293,6 @@ fn install_copy_cut_paste(runner_ref: &WebRunner, target: &EventTarget) -> Resul
|
||||
}
|
||||
})?;
|
||||
|
||||
#[cfg(web_sys_unstable_apis)]
|
||||
runner_ref.add_event_listener(target, "cut", |event: web_sys::ClipboardEvent, runner| {
|
||||
if runner.input.raw.focused {
|
||||
runner.input.raw.events.push(egui::Event::Cut);
|
||||
@@ -311,7 +309,6 @@ fn install_copy_cut_paste(runner_ref: &WebRunner, target: &EventTarget) -> Resul
|
||||
event.prevent_default();
|
||||
})?;
|
||||
|
||||
#[cfg(web_sys_unstable_apis)]
|
||||
runner_ref.add_event_listener(target, "copy", |event: web_sys::ClipboardEvent, runner| {
|
||||
if runner.input.raw.focused {
|
||||
runner.input.raw.events.push(egui::Event::Copy);
|
||||
|
||||
@@ -168,7 +168,6 @@ fn set_cursor_icon(cursor: egui::CursorIcon) -> Option<()> {
|
||||
}
|
||||
|
||||
/// Set the clipboard text.
|
||||
#[cfg(web_sys_unstable_apis)]
|
||||
fn set_clipboard_text(s: &str) {
|
||||
if let Some(window) = web_sys::window() {
|
||||
let promise = window.navigator().clipboard().write_text(s);
|
||||
|
||||
@@ -35,11 +35,6 @@ impl WebRunner {
|
||||
/// Will install a panic handler that will catch and log any panics
|
||||
#[allow(clippy::new_without_default)]
|
||||
pub fn new() -> Self {
|
||||
#[cfg(not(web_sys_unstable_apis))]
|
||||
log::warn!(
|
||||
"eframe compiled without RUSTFLAGS='--cfg=web_sys_unstable_apis'. Copying text won't work."
|
||||
);
|
||||
|
||||
let panic_handler = PanicHandler::install();
|
||||
|
||||
Self {
|
||||
|
||||
Reference in New Issue
Block a user