9
9
from arcade import uicolor
10
10
from arcade .gui import UIEvent , UIMousePressEvent
11
11
from arcade .gui .events import UIOnChangeEvent , UIOnClickEvent
12
+ from arcade .gui .experimental .controller import UIControllerButtonPressEvent
13
+ from arcade .gui .experimental .focus import UIFocusMixin
12
14
from arcade .gui .ui_manager import UIManager
13
15
from arcade .gui .widgets import UILayout , UIWidget
14
16
from arcade .gui .widgets .buttons import UIFlatButton
15
17
from arcade .gui .widgets .layout import UIBoxLayout
16
18
17
19
18
- class _UIDropdownOverlay (UIBoxLayout ):
20
+ class _UIDropdownOverlay (UIFocusMixin , UIBoxLayout ):
19
21
"""Represents the dropdown options overlay.
20
22
21
23
Currently only handles closing the overlay when clicked outside of the options.
@@ -37,6 +39,13 @@ def on_event(self, event: UIEvent) -> Optional[bool]:
37
39
if not self .rect .point_in_rect ((event .x , event .y )):
38
40
self .hide ()
39
41
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
+
40
49
return super ().on_event (event )
41
50
42
51
@@ -188,6 +197,8 @@ def _update_options(self):
188
197
)
189
198
button .on_click = self ._on_option_click
190
199
200
+ self ._overlay .detect_focusable_widgets ()
201
+
191
202
def _find_ui_manager (self ):
192
203
# search tree for UIManager
193
204
parent = self .parent
0 commit comments