mirror of
https://github.com/emilk/egui.git
synced 2026-08-31 13:50:04 -04:00
* Closes https://github.com/emilk/egui/issues/1010 ### In short You can now put interactive widgets, like buttons and hyperlinks, in an tooltip using `on_hover_ui`. If you do, the tooltip will stay open as long as the user hovers it. There is a new demo for this in the egui demo app (egui.rs):  ### Design Tooltips can now contain interactive widgets, such as buttons and links. If they do, they will stay open when the user moves their pointer over them. Widgets that do not contain interactive widgets disappear as soon as you no longer hover the underlying widget, just like before. This is so that they won't annoy the user. To ensure not all tooltips with text in them are considered interactive, `selectable_labels` is `false` for tooltips contents by default. If you want selectable text in tooltips, either change the `selectable_labels` setting, or use `Label::selectable`. ```rs ui.label("Hover me").on_hover_ui(|ui| { ui.style_mut().interaction.selectable_labels = true; ui.label("This text can be selected."); ui.add(egui::Label::new("This too.").selectable(true)); }); ``` ### Changes * Layers in `Order::Tooltip` can now be interacted with
64 lines
1.5 KiB
Rust
64 lines
1.5 KiB
Rust
//! Demo-code for showing how egui is used.
|
|
//!
|
|
//! The demo-code is also used in benchmarks and tests.
|
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
pub mod about;
|
|
pub mod code_editor;
|
|
pub mod code_example;
|
|
pub mod context_menu;
|
|
pub mod dancing_strings;
|
|
pub mod demo_app_windows;
|
|
pub mod drag_and_drop;
|
|
pub mod extra_viewport;
|
|
pub mod font_book;
|
|
pub mod frame_demo;
|
|
pub mod highlighting;
|
|
pub mod layout_test;
|
|
pub mod misc_demo_window;
|
|
pub mod multi_touch;
|
|
pub mod paint_bezier;
|
|
pub mod painting;
|
|
pub mod pan_zoom;
|
|
pub mod panels;
|
|
pub mod password;
|
|
pub mod plot_demo;
|
|
pub mod scrolling;
|
|
pub mod sliders;
|
|
pub mod strip_demo;
|
|
pub mod table_demo;
|
|
pub mod tests;
|
|
pub mod text_edit;
|
|
pub mod text_layout;
|
|
pub mod toggle_switch;
|
|
pub mod tooltips;
|
|
pub mod widget_gallery;
|
|
pub mod window_options;
|
|
|
|
pub use {
|
|
about::About, demo_app_windows::DemoWindows, misc_demo_window::MiscDemoWindow,
|
|
widget_gallery::WidgetGallery,
|
|
};
|
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
/// Something to view in the demo windows
|
|
pub trait View {
|
|
fn ui(&mut self, ui: &mut egui::Ui);
|
|
}
|
|
|
|
/// Something to view
|
|
pub trait Demo {
|
|
/// Is the demo enabled for this integration?
|
|
fn is_enabled(&self, _ctx: &egui::Context) -> bool {
|
|
true
|
|
}
|
|
|
|
/// `&'static` so we can also use it as a key to store open/close state.
|
|
fn name(&self) -> &'static str;
|
|
|
|
/// Show windows, etc
|
|
fn show(&mut self, ctx: &egui::Context, open: &mut bool);
|
|
}
|