@@ -11,8 +11,10 @@ use tracing::{debug, error};
1111
1212#[ derive( Debug ) ]
1313pub struct PopupCacheValue {
14- // pub name: String,
1514 pub content : gtk:: Box ,
15+ /// Whether this module disallows the popover widget from using autohide.
16+ /// Where popups are controlled via hover, autohide can cause issues.
17+ pub disable_autohide : bool ,
1618}
1719
1820#[ derive( Debug , Clone , Copy ) ]
@@ -30,6 +32,7 @@ pub struct Popup {
3032 pub button_cache : Rc < RefCell < Vec < Button > > > ,
3133 pos : BarPosition ,
3234 current_widget : Rc < RefCell < Option < CurrentWidgetInfo > > > ,
35+ autohide : bool ,
3336}
3437
3538impl Debug for Popup {
@@ -84,6 +87,7 @@ impl Popup {
8487 button_finder_cache : rc_mut ! ( HashMap :: new( ) ) ,
8588 pos,
8689 current_widget : rc_mut ! ( None ) ,
90+ autohide,
8791 }
8892 }
8993
@@ -102,6 +106,7 @@ impl Popup {
102106 key,
103107 PopupCacheValue {
104108 content : content. container . clone ( ) ,
109+ disable_autohide : content. disable_autohide ,
105110 } ,
106111 ) ;
107112
@@ -128,7 +133,11 @@ impl Popup {
128133 pub fn show ( & self , widget_id : usize , button_id : usize ) {
129134 self . clear_window ( ) ;
130135
131- if let Some ( PopupCacheValue { content, .. } ) = self . container_cache . borrow ( ) . get ( & widget_id)
136+ if let Some ( PopupCacheValue {
137+ content,
138+ disable_autohide,
139+ ..
140+ } ) = self . container_cache . borrow ( ) . get ( & widget_id)
132141 {
133142 * self . current_widget . borrow_mut ( ) = Some ( CurrentWidgetInfo { widget_id } ) ;
134143
@@ -151,6 +160,11 @@ impl Popup {
151160 self . popover . set_child ( Some ( content) ) ;
152161 self . popover . unparent ( ) ;
153162 self . popover . set_parent ( & button) ;
163+
164+ if * disable_autohide {
165+ self . popover . set_autohide ( false ) ;
166+ }
167+
154168 self . popover . popup ( ) ;
155169 }
156170 }
@@ -163,14 +177,23 @@ impl Popup {
163177 pub fn show_for ( & self , widget_id : usize , button : & Button ) -> bool {
164178 self . clear_window ( ) ;
165179
166- if let Some ( PopupCacheValue { content, .. } ) = self . container_cache . borrow ( ) . get ( & widget_id)
180+ if let Some ( PopupCacheValue {
181+ content,
182+ disable_autohide,
183+ ..
184+ } ) = self . container_cache . borrow ( ) . get ( & widget_id)
167185 {
168186 * self . current_widget . borrow_mut ( ) = Some ( CurrentWidgetInfo { widget_id } ) ;
169187
170188 content. add_css_class ( "popup" ) ;
171189 self . popover . set_child ( Some ( content) ) ;
172190 self . popover . unparent ( ) ;
173191 self . popover . set_parent ( button) ;
192+
193+ if * disable_autohide {
194+ self . popover . set_autohide ( false ) ;
195+ }
196+
174197 self . popover . popup ( ) ;
175198
176199 true
@@ -181,6 +204,7 @@ impl Popup {
181204
182205 fn clear_window ( & self ) {
183206 self . popover . set_child ( None :: < & gtk:: Box > ) ;
207+ self . popover . set_autohide ( self . autohide ) ;
184208 }
185209
186210 /// Hides the popup
0 commit comments