mirror of
https://github.com/emilk/egui.git
synced 2026-09-02 06:40:06 -04:00
Add Context::open_url and Context::copy_text (#3380)
* Add Context::open_url * Add `Context::copy_text` * Fix doctest * Fix another doctest
This commit is contained in:
@@ -195,7 +195,7 @@ fn ui_resource(ui: &mut egui::Ui, resource: &Resource) {
|
||||
if let Some(text) = &text {
|
||||
let tooltip = "Click to copy the response body";
|
||||
if ui.button("📋").on_hover_text(tooltip).clicked() {
|
||||
ui.output_mut(|o| o.copied_text = text.clone());
|
||||
ui.ctx().copy_text(text.clone());
|
||||
}
|
||||
ui.separator();
|
||||
}
|
||||
|
||||
@@ -396,7 +396,8 @@ impl WrapApp {
|
||||
{
|
||||
selected_anchor = anchor;
|
||||
if frame.is_web() {
|
||||
ui.output_mut(|o| o.open_url(format!("#{anchor}")));
|
||||
ui.ctx()
|
||||
.open_url(egui::OpenUrl::same_tab(format!("#{anchor}")));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -408,7 +409,7 @@ impl WrapApp {
|
||||
if clock_button(ui, crate::seconds_since_midnight()).clicked() {
|
||||
self.state.selected_anchor = Anchor::Clock;
|
||||
if frame.is_web() {
|
||||
ui.output_mut(|o| o.open_url("#clock"));
|
||||
ui.ctx().open_url(egui::OpenUrl::same_tab("#clock"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user