Skip to content

Commit f37ef38

Browse files
eruvanospushfoo
authored andcommitted
fix hide method of dropdown when no parent exists (pythonarcade#2539)
1 parent b76ab32 commit f37ef38

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

arcade/gui/widgets/dropdown.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,8 @@ def show(self, manager: UIManager):
2828

2929
def hide(self):
3030
"""Hide the overlay."""
31-
self.parent.remove(self)
31+
if self.parent:
32+
self.parent.remove(self)
3233

3334
def on_event(self, event: UIEvent) -> Optional[bool]:
3435
if isinstance(event, UIMousePressEvent):
@@ -164,8 +165,8 @@ def _on_button_click(self, _: UIOnClickEvent):
164165

165166
def _on_option_click(self, event: UIOnClickEvent):
166167
source: UIFlatButton = event.source
167-
self.value = source.text
168168
self._overlay.hide()
169+
self.value = source.text
169170

170171
def do_layout(self):
171172
"""Position the overlay, this is not a common thing to do in do_layout,

0 commit comments

Comments
 (0)