diff --git a/pygame_gui/elements/ui_button.py b/pygame_gui/elements/ui_button.py index d1d824de..12f2045b 100644 --- a/pygame_gui/elements/ui_button.py +++ b/pygame_gui/elements/ui_button.py @@ -804,9 +804,9 @@ def hide(self): """ In addition to the base UIElement.hide() - Change the hovered state to a normal state. """ - super().hide() - - self.on_unhovered() + if self.visible: + super().hide() + self.on_unhovered() def on_locale_changed(self): font = self.ui_theme.get_font(self.combined_element_ids) diff --git a/pygame_gui/elements/ui_drop_down_menu.py b/pygame_gui/elements/ui_drop_down_menu.py index c391b06b..d78490d2 100644 --- a/pygame_gui/elements/ui_drop_down_menu.py +++ b/pygame_gui/elements/ui_drop_down_menu.py @@ -629,6 +629,9 @@ def hide(self): """ Hide selected_option_button and open_button. """ + if not self.visible: + return + self.visible = False if self.open_button is not None: @@ -1013,6 +1016,9 @@ def hide(self): hide() method, which begins a transition of the UIDropDownMenu to the 'closed' state, and call the hide() method of the 'closed' state which hides all it's children widgets. """ + if not self.visible: + return + super().hide() if self.current_state is not None and self.menu_states is not None: if self.current_state == self.menu_states['expanded']: diff --git a/pygame_gui/elements/ui_horizontal_scroll_bar.py b/pygame_gui/elements/ui_horizontal_scroll_bar.py index 57183917..3e558554 100644 --- a/pygame_gui/elements/ui_horizontal_scroll_bar.py +++ b/pygame_gui/elements/ui_horizontal_scroll_bar.py @@ -613,6 +613,9 @@ def hide(self): In addition to the base UIElement.hide() - hide the self.button_container which will propagate and hide all the buttons. """ + if not self.visible: + return + super().hide() if self.button_container is not None: self.button_container.hide() diff --git a/pygame_gui/elements/ui_horizontal_slider.py b/pygame_gui/elements/ui_horizontal_slider.py index 5b42683c..179c13ff 100644 --- a/pygame_gui/elements/ui_horizontal_slider.py +++ b/pygame_gui/elements/ui_horizontal_slider.py @@ -567,6 +567,9 @@ def hide(self): In addition to the base UIElement.hide() - hide the sliding button and hide the button_container which will propagate and hide the left and right buttons. """ + if not self.visible: + return + super().hide() if self.sliding_button is not None: diff --git a/pygame_gui/elements/ui_panel.py b/pygame_gui/elements/ui_panel.py index 2ad47ec0..2dbfcef1 100644 --- a/pygame_gui/elements/ui_panel.py +++ b/pygame_gui/elements/ui_panel.py @@ -299,6 +299,9 @@ def hide(self): """ In addition to the base UIElement.hide() - call hide() of owned container - panel_container. """ + if not self.visible: + return + if self.panel_container is not None: self.panel_container.hide() super().hide() diff --git a/pygame_gui/elements/ui_scrolling_container.py b/pygame_gui/elements/ui_scrolling_container.py index ac83dd43..dd05dae8 100644 --- a/pygame_gui/elements/ui_scrolling_container.py +++ b/pygame_gui/elements/ui_scrolling_container.py @@ -531,6 +531,9 @@ def hide(self): it's visibility will propagate to them - there is no need to call their hide() methods separately. """ + if not self.visible: + return + if self._root_container is not None: self._root_container.hide() super().hide() diff --git a/pygame_gui/elements/ui_selection_list.py b/pygame_gui/elements/ui_selection_list.py index 35a1a37b..350aadd9 100644 --- a/pygame_gui/elements/ui_selection_list.py +++ b/pygame_gui/elements/ui_selection_list.py @@ -728,6 +728,9 @@ def hide(self): children of list_and_scroll_bar_container, so it's visibility will propagate to them - there is no need to call their hide() methods separately. """ + if not self.visible: + return + super().hide() if self.list_and_scroll_bar_container is not None: self.list_and_scroll_bar_container.hide() diff --git a/pygame_gui/elements/ui_tab_container.py b/pygame_gui/elements/ui_tab_container.py index 5934dc65..d1fa4350 100644 --- a/pygame_gui/elements/ui_tab_container.py +++ b/pygame_gui/elements/ui_tab_container.py @@ -183,6 +183,9 @@ def hide(self): In addition to the base UIElement.hide() - hide the _window_root_container which will propagate and hide all the children. """ + if not self.visible: + return + super().hide() if self._root_container is not None: self._root_container.hide() diff --git a/pygame_gui/elements/ui_text_box.py b/pygame_gui/elements/ui_text_box.py index 9bcc0613..75d699f3 100644 --- a/pygame_gui/elements/ui_text_box.py +++ b/pygame_gui/elements/ui_text_box.py @@ -1221,6 +1221,9 @@ def hide(self): """ In addition to the base UIElement.hide() - call hide() of scroll_bar if it exists. """ + if not self.visible: + return + super().hide() if self.scroll_bar is not None: diff --git a/pygame_gui/elements/ui_vertical_scroll_bar.py b/pygame_gui/elements/ui_vertical_scroll_bar.py index 09aa5549..bf5d26ba 100644 --- a/pygame_gui/elements/ui_vertical_scroll_bar.py +++ b/pygame_gui/elements/ui_vertical_scroll_bar.py @@ -609,6 +609,9 @@ def hide(self): In addition to the base UIElement.hide() - hide the self.button_container which will propagate and hide all the buttons. """ + if not self.visible: + return + super().hide() if self.button_container is not None: self.button_container.hide() diff --git a/pygame_gui/elements/ui_window.py b/pygame_gui/elements/ui_window.py index 02efc777..993e178e 100644 --- a/pygame_gui/elements/ui_window.py +++ b/pygame_gui/elements/ui_window.py @@ -764,6 +764,9 @@ def hide(self): In addition to the base UIElement.hide() - hide the _window_root_container which will propagate and hide all the children. """ + if not self.visible: + return + super().hide() if self._window_root_container is not None: self._window_root_container.hide() diff --git a/pygame_gui/windows/ui_colour_picker_dialog.py b/pygame_gui/windows/ui_colour_picker_dialog.py index 9f7d3657..274a90c0 100644 --- a/pygame_gui/windows/ui_colour_picker_dialog.py +++ b/pygame_gui/windows/ui_colour_picker_dialog.py @@ -286,6 +286,9 @@ def hide(self): In addition to the base UIElement.hide() - call hide() of the element_container - which will propagate to the sub-elements - label, entry and slider. """ + if not self.visible: + return + super().hide() if self.element_container is not None: self.element_container.hide()