mirror of
https://github.com/emilk/egui.git
synced 2026-09-01 06:10:06 -04:00
Make on_disabled_hover_ui respect tooltip_delay (#4012)
* Closes <https://github.com/emilk/egui/issues/3997>
This commit is contained in:
@@ -233,6 +233,7 @@ fn label_ui(ui: &mut egui::Ui) {
|
||||
#[cfg_attr(feature = "serde", serde(default))]
|
||||
pub struct Widgets {
|
||||
angle: f32,
|
||||
enabled: bool,
|
||||
password: String,
|
||||
}
|
||||
|
||||
@@ -240,6 +241,7 @@ impl Default for Widgets {
|
||||
fn default() -> Self {
|
||||
Self {
|
||||
angle: std::f32::consts::TAU / 3.0,
|
||||
enabled: true,
|
||||
password: "hunter2".to_owned(),
|
||||
}
|
||||
}
|
||||
@@ -247,7 +249,11 @@ impl Default for Widgets {
|
||||
|
||||
impl Widgets {
|
||||
pub fn ui(&mut self, ui: &mut Ui) {
|
||||
let Self { angle, password } = self;
|
||||
let Self {
|
||||
angle,
|
||||
enabled,
|
||||
password,
|
||||
} = self;
|
||||
ui.vertical_centered(|ui| {
|
||||
ui.add(crate::egui_github_link_file_line!());
|
||||
});
|
||||
@@ -260,8 +266,20 @@ impl Widgets {
|
||||
});
|
||||
let _ = ui.button("A button you can never press");
|
||||
};
|
||||
ui.label("Tooltips can be more than just simple text.")
|
||||
.on_hover_ui(tooltip_ui);
|
||||
let disabled_tooltip_ui = |ui: &mut Ui| {
|
||||
ui.heading("Different tooltip when widget is disabled");
|
||||
ui.horizontal(|ui| {
|
||||
ui.label("This tooltip was created with");
|
||||
ui.monospace(".on_disabled_hover_ui(…)");
|
||||
});
|
||||
};
|
||||
ui.checkbox(enabled, "Enabled");
|
||||
ui.add_enabled(
|
||||
*enabled,
|
||||
egui::Label::new("Tooltips can be more than just simple text."),
|
||||
)
|
||||
.on_hover_ui(tooltip_ui)
|
||||
.on_disabled_hover_ui(disabled_tooltip_ui);
|
||||
|
||||
ui.separator();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user