1
0
mirror of https://github.com/emilk/egui.git synced 2026-09-01 14:20:04 -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

@@ -820,9 +820,11 @@ impl State {
window: &Window,
platform_output: egui::PlatformOutput,
) {
#![allow(deprecated)]
profiling::function_scope!();
let egui::PlatformOutput {
commands,
cursor_icon,
open_url,
copied_text,
@@ -835,6 +837,17 @@ impl State {
request_discard_reasons: _, // `egui::Context::run` handles this
} = platform_output;
for command in commands {
match command {
egui::OutputCommand::CopyText(text) => {
self.clipboard.set(text);
}
egui::OutputCommand::OpenUrl(open_url) => {
open_url_in_browser(&open_url.url);
}
}
}
self.set_cursor_icon(window, cursor_icon);
if let Some(open_url) = open_url {