Skip to content

Commit 78a0687

Browse files
committed
make UIDropDown support controller
1 parent 7411f01 commit 78a0687

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

Diff for: arcade/gui/widgets/dropdown.py

+12-1
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,15 @@
99
from arcade import uicolor
1010
from arcade.gui import UIEvent, UIMousePressEvent
1111
from arcade.gui.events import UIOnChangeEvent, UIOnClickEvent
12+
from arcade.gui.experimental.controller import UIControllerButtonPressEvent
13+
from arcade.gui.experimental.focus import UIFocusMixin
1214
from arcade.gui.ui_manager import UIManager
1315
from arcade.gui.widgets import UILayout, UIWidget
1416
from arcade.gui.widgets.buttons import UIFlatButton
1517
from arcade.gui.widgets.layout import UIBoxLayout
1618

1719

18-
class _UIDropdownOverlay(UIBoxLayout):
20+
class _UIDropdownOverlay(UIFocusMixin, UIBoxLayout):
1921
"""Represents the dropdown options overlay.
2022
2123
Currently only handles closing the overlay when clicked outside of the options.
@@ -37,6 +39,13 @@ def on_event(self, event: UIEvent) -> Optional[bool]:
3739
if not self.rect.point_in_rect((event.x, event.y)):
3840
self.hide()
3941
return EVENT_HANDLED
42+
43+
if isinstance(event, UIControllerButtonPressEvent):
44+
# TODO find a better and more generic way to handle controller events for this
45+
if event.button == "b":
46+
self.hide()
47+
return EVENT_HANDLED
48+
4049
return super().on_event(event)
4150

4251

@@ -188,6 +197,8 @@ def _update_options(self):
188197
)
189198
button.on_click = self._on_option_click
190199

200+
self._overlay.detect_focusable_widgets()
201+
191202
def _find_ui_manager(self):
192203
# search tree for UIManager
193204
parent = self.parent

0 commit comments

Comments
 (0)