@@ -550,15 +550,37 @@ impl Response {
550
550
/// ```
551
551
#[ doc( alias = "tooltip" ) ]
552
552
pub fn on_hover_ui ( self , add_contents : impl FnOnce ( & mut Ui ) ) -> Self {
553
- if self . flags . contains ( Flags :: ENABLED ) && self . should_show_hover_ui ( ) {
553
+ self . on_hover_ui_interactive ( true , add_contents)
554
+ }
555
+
556
+ /// Show this UI if the widget was hovered.
557
+ ///
558
+ /// Argument `interactive` controls whether mouse can interact with interactive tooltip.
559
+ pub fn on_hover_ui_interactive (
560
+ self ,
561
+ interactive : bool ,
562
+ add_contents : impl FnOnce ( & mut Ui ) ,
563
+ ) -> Self {
564
+ if self . flags . contains ( Flags :: ENABLED ) && self . should_show_hover_ui ( interactive) {
554
565
self . show_tooltip_ui ( add_contents) ;
555
566
}
556
567
self
557
568
}
558
569
559
570
/// Show this UI when hovering if the widget is disabled.
560
571
pub fn on_disabled_hover_ui ( self , add_contents : impl FnOnce ( & mut Ui ) ) -> Self {
561
- if !self . enabled ( ) && self . should_show_hover_ui ( ) {
572
+ self . on_disabled_hover_ui_interactive ( true , add_contents)
573
+ }
574
+
575
+ /// Show this UI when hovering if the widget is disabled.
576
+ ///
577
+ /// Argument `interactive` controls whether mouse can interact with interactive tooltip.
578
+ pub fn on_disabled_hover_ui_interactive (
579
+ self ,
580
+ interactive : bool ,
581
+ add_contents : impl FnOnce ( & mut Ui ) ,
582
+ ) -> Self {
583
+ if !self . enabled ( ) && self . should_show_hover_ui ( interactive) {
562
584
crate :: containers:: show_tooltip_for (
563
585
& self . ctx ,
564
586
self . layer_id ,
@@ -572,7 +594,18 @@ impl Response {
572
594
573
595
/// Like `on_hover_ui`, but show the ui next to cursor.
574
596
pub fn on_hover_ui_at_pointer ( self , add_contents : impl FnOnce ( & mut Ui ) ) -> Self {
575
- if self . enabled ( ) && self . should_show_hover_ui ( ) {
597
+ self . on_hover_ui_at_pointer_interactive ( true , add_contents)
598
+ }
599
+
600
+ /// Like `on_hover_ui`, but show the ui next to cursor.
601
+ ///
602
+ /// Argument `interactive` controls whether mouse can interact with interactive tooltip.
603
+ pub fn on_hover_ui_at_pointer_interactive (
604
+ self ,
605
+ interactive : bool ,
606
+ add_contents : impl FnOnce ( & mut Ui ) ,
607
+ ) -> Self {
608
+ if self . enabled ( ) && self . should_show_hover_ui ( interactive) {
576
609
crate :: containers:: show_tooltip_at_pointer (
577
610
& self . ctx ,
578
611
self . layer_id ,
@@ -610,7 +643,7 @@ impl Response {
610
643
crate :: popup:: was_tooltip_open_last_frame ( & self . ctx , self . id )
611
644
}
612
645
613
- fn should_show_hover_ui ( & self ) -> bool {
646
+ fn should_show_hover_ui ( & self , allow_interactive : bool ) -> bool {
614
647
if self . ctx . memory ( |mem| mem. everything_is_visible ( ) ) {
615
648
return true ;
616
649
}
@@ -662,12 +695,13 @@ impl Response {
662
695
let tooltip_id = crate :: next_tooltip_id ( & self . ctx , self . id ) ;
663
696
let tooltip_layer_id = LayerId :: new ( Order :: Tooltip , tooltip_id) ;
664
697
665
- let tooltip_has_interactive_widget = self . ctx . viewport ( |vp| {
666
- vp. prev_pass
667
- . widgets
668
- . get_layer ( tooltip_layer_id)
669
- . any ( |w| w. enabled && w. sense . interactive ( ) )
670
- } ) ;
698
+ let tooltip_has_interactive_widget = allow_interactive
699
+ && self . ctx . viewport ( |vp| {
700
+ vp. prev_pass
701
+ . widgets
702
+ . get_layer ( tooltip_layer_id)
703
+ . any ( |w| w. enabled && w. sense . interactive ( ) )
704
+ } ) ;
671
705
672
706
if tooltip_has_interactive_widget {
673
707
// We keep the tooltip open if hovered,
0 commit comments