mirror of
https://github.com/emilk/egui.git
synced 2026-09-01 14:20:04 -04:00
Make on_disabled_hover_ui respect tooltip_delay (#4012)
* Closes <https://github.com/emilk/egui/issues/3997>
This commit is contained in:
@@ -438,7 +438,7 @@ impl Response {
|
||||
/// If you call this multiple times the tooltips will stack underneath the previous ones.
|
||||
#[doc(alias = "tooltip")]
|
||||
pub fn on_hover_ui(self, add_contents: impl FnOnce(&mut Ui)) -> Self {
|
||||
if self.should_show_hover_ui() {
|
||||
if self.enabled && self.should_show_hover_ui() {
|
||||
crate::containers::show_tooltip_for(
|
||||
&self.ctx,
|
||||
self.id.with("__tooltip"),
|
||||
@@ -451,7 +451,7 @@ impl Response {
|
||||
|
||||
/// Show this UI when hovering if the widget is disabled.
|
||||
pub fn on_disabled_hover_ui(self, add_contents: impl FnOnce(&mut Ui)) -> Self {
|
||||
if !self.enabled && self.ctx.rect_contains_pointer(self.layer_id, self.rect) {
|
||||
if !self.enabled && self.should_show_hover_ui() {
|
||||
crate::containers::show_tooltip_for(
|
||||
&self.ctx,
|
||||
self.id.with("__tooltip"),
|
||||
@@ -464,7 +464,7 @@ impl Response {
|
||||
|
||||
/// Like `on_hover_ui`, but show the ui next to cursor.
|
||||
pub fn on_hover_ui_at_pointer(self, add_contents: impl FnOnce(&mut Ui)) -> Self {
|
||||
if self.should_show_hover_ui() {
|
||||
if self.enabled && self.should_show_hover_ui() {
|
||||
crate::containers::show_tooltip_at_pointer(
|
||||
&self.ctx,
|
||||
self.id.with("__tooltip"),
|
||||
@@ -484,7 +484,11 @@ impl Response {
|
||||
return true;
|
||||
}
|
||||
|
||||
if !self.hovered || !self.ctx.input(|i| i.pointer.has_pointer()) {
|
||||
if self.enabled {
|
||||
if !self.hovered || !self.ctx.input(|i| i.pointer.has_pointer()) {
|
||||
return false;
|
||||
}
|
||||
} else if !self.ctx.rect_contains_pointer(self.layer_id, self.rect) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -505,8 +509,9 @@ impl Response {
|
||||
|
||||
if 0.0 < time_til_tooltip {
|
||||
// Wait until the mouse has been still for a while
|
||||
self.ctx
|
||||
.request_repaint_after(std::time::Duration::from_secs_f32(time_til_tooltip));
|
||||
if let Ok(duration) = std::time::Duration::try_from_secs_f32(time_til_tooltip) {
|
||||
self.ctx.request_repaint_after(duration);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user