Skip to content

Commit ce63b0b

Browse files
authored
Merge pull request #630 from rbaltrusch/fix_hiding_hidden_unhover
Fix #610 by not hiding if not visible
2 parents 9b5a232 + d302e11 commit ce63b0b

12 files changed

+39
-3
lines changed

pygame_gui/elements/ui_button.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -804,9 +804,9 @@ def hide(self):
804804
"""
805805
In addition to the base UIElement.hide() - Change the hovered state to a normal state.
806806
"""
807-
super().hide()
808-
809-
self.on_unhovered()
807+
if self.visible:
808+
super().hide()
809+
self.on_unhovered()
810810

811811
def on_locale_changed(self):
812812
font = self.ui_theme.get_font(self.combined_element_ids)

pygame_gui/elements/ui_drop_down_menu.py

+6
Original file line numberDiff line numberDiff line change
@@ -629,6 +629,9 @@ def hide(self):
629629
"""
630630
Hide selected_option_button and open_button.
631631
"""
632+
if not self.visible:
633+
return
634+
632635
self.visible = False
633636

634637
if self.open_button is not None:
@@ -1013,6 +1016,9 @@ def hide(self):
10131016
hide() method, which begins a transition of the UIDropDownMenu to the 'closed' state, and
10141017
call the hide() method of the 'closed' state which hides all it's children widgets.
10151018
"""
1019+
if not self.visible:
1020+
return
1021+
10161022
super().hide()
10171023
if self.current_state is not None and self.menu_states is not None:
10181024
if self.current_state == self.menu_states['expanded']:

pygame_gui/elements/ui_horizontal_scroll_bar.py

+3
Original file line numberDiff line numberDiff line change
@@ -613,6 +613,9 @@ def hide(self):
613613
In addition to the base UIElement.hide() - hide the self.button_container which
614614
will propagate and hide all the buttons.
615615
"""
616+
if not self.visible:
617+
return
618+
616619
super().hide()
617620
if self.button_container is not None:
618621
self.button_container.hide()

pygame_gui/elements/ui_horizontal_slider.py

+3
Original file line numberDiff line numberDiff line change
@@ -567,6 +567,9 @@ def hide(self):
567567
In addition to the base UIElement.hide() - hide the sliding button and hide
568568
the button_container which will propagate and hide the left and right buttons.
569569
"""
570+
if not self.visible:
571+
return
572+
570573
super().hide()
571574

572575
if self.sliding_button is not None:

pygame_gui/elements/ui_panel.py

+3
Original file line numberDiff line numberDiff line change
@@ -299,6 +299,9 @@ def hide(self):
299299
"""
300300
In addition to the base UIElement.hide() - call hide() of owned container - panel_container.
301301
"""
302+
if not self.visible:
303+
return
304+
302305
if self.panel_container is not None:
303306
self.panel_container.hide()
304307
super().hide()

pygame_gui/elements/ui_scrolling_container.py

+3
Original file line numberDiff line numberDiff line change
@@ -531,6 +531,9 @@ def hide(self):
531531
it's visibility will propagate to them - there is no need to call their hide() methods
532532
separately.
533533
"""
534+
if not self.visible:
535+
return
536+
534537
if self._root_container is not None:
535538
self._root_container.hide()
536539
super().hide()

pygame_gui/elements/ui_selection_list.py

+3
Original file line numberDiff line numberDiff line change
@@ -728,6 +728,9 @@ def hide(self):
728728
children of list_and_scroll_bar_container, so it's visibility will propagate to them -
729729
there is no need to call their hide() methods separately.
730730
"""
731+
if not self.visible:
732+
return
733+
731734
super().hide()
732735
if self.list_and_scroll_bar_container is not None:
733736
self.list_and_scroll_bar_container.hide()

pygame_gui/elements/ui_tab_container.py

+3
Original file line numberDiff line numberDiff line change
@@ -183,6 +183,9 @@ def hide(self):
183183
In addition to the base UIElement.hide() - hide the _window_root_container which will
184184
propagate and hide all the children.
185185
"""
186+
if not self.visible:
187+
return
188+
186189
super().hide()
187190
if self._root_container is not None:
188191
self._root_container.hide()

pygame_gui/elements/ui_text_box.py

+3
Original file line numberDiff line numberDiff line change
@@ -1221,6 +1221,9 @@ def hide(self):
12211221
"""
12221222
In addition to the base UIElement.hide() - call hide() of scroll_bar if it exists.
12231223
"""
1224+
if not self.visible:
1225+
return
1226+
12241227
super().hide()
12251228

12261229
if self.scroll_bar is not None:

pygame_gui/elements/ui_vertical_scroll_bar.py

+3
Original file line numberDiff line numberDiff line change
@@ -609,6 +609,9 @@ def hide(self):
609609
In addition to the base UIElement.hide() - hide the self.button_container which will
610610
propagate and hide all the buttons.
611611
"""
612+
if not self.visible:
613+
return
614+
612615
super().hide()
613616
if self.button_container is not None:
614617
self.button_container.hide()

pygame_gui/elements/ui_window.py

+3
Original file line numberDiff line numberDiff line change
@@ -764,6 +764,9 @@ def hide(self):
764764
In addition to the base UIElement.hide() - hide the _window_root_container which will
765765
propagate and hide all the children.
766766
"""
767+
if not self.visible:
768+
return
769+
767770
super().hide()
768771
if self._window_root_container is not None:
769772
self._window_root_container.hide()

pygame_gui/windows/ui_colour_picker_dialog.py

+3
Original file line numberDiff line numberDiff line change
@@ -286,6 +286,9 @@ def hide(self):
286286
In addition to the base UIElement.hide() - call hide() of the element_container
287287
- which will propagate to the sub-elements - label, entry and slider.
288288
"""
289+
if not self.visible:
290+
return
291+
289292
super().hide()
290293
if self.element_container is not None:
291294
self.element_container.hide()

0 commit comments

Comments
 (0)