1
0
mirror of https://github.com/emilk/egui.git synced 2026-08-30 13:20:05 -04:00

Add OutputCommand for copying text and opening URL:s (#5532)

Add `OutputCommand` for copying text and opening URL:s

* Part of https://github.com/emilk/egui/issues/5424
* Adds `egui::OutputComm
* Part of https://github.com/emilk/egui/issues/5424and`
* Adds `PlatformOutput::commands`
* Deprecates `PlatformOutput::open_url`
* Deprecates `PlatformOutput::copied_text`
This commit is contained in:
Emil Ernerfeldt
2024-12-29 11:59:51 +01:00
committed by GitHub
parent 1e0f3a5e2d
commit e2c7e9e733
7 changed files with 71 additions and 15 deletions

View File

@@ -292,12 +292,15 @@ impl AppRunner {
}
fn handle_platform_output(&self, platform_output: egui::PlatformOutput) {
#![allow(deprecated)]
#[cfg(feature = "web_screen_reader")]
if self.egui_ctx.options(|o| o.screen_reader) {
super::screen_reader::speak(&platform_output.events_description());
}
let egui::PlatformOutput {
commands,
cursor_icon,
open_url,
copied_text,
@@ -310,7 +313,19 @@ impl AppRunner {
request_discard_reasons: _, // handled by `Context::run`
} = platform_output;
for command in commands {
match command {
egui::OutputCommand::CopyText(text) => {
super::set_clipboard_text(&text);
}
egui::OutputCommand::OpenUrl(open_url) => {
super::open_url(&open_url.url, open_url.new_tab);
}
}
}
super::set_cursor_icon(cursor_icon);
if let Some(open) = open_url {
super::open_url(&open.url, open.new_tab);
}