Allow dropdowns to be opened by MouseDown event
See https://github.com/ppy/osu-framework/discussions/6584
Adds ToggleOnMouseDown boolean property for Dropdown and DropdownHeader.
The flag will use MouseDownEvent instead of ClickEvent for toggling the menu. Dropdown handles MouseUpEvent, looking for active hovers and selecting preselected items if the menu is hovered. Dropdown should close if cursor was released outside the menu and should stay open if it is released on the DropdownHeader.
For clarity I'm not willing to review this further until I get buy-in from @ppy/team-client that everyone is fine with dropdowns changing UX on the fly depending on whether they're inside a scroll or not (https://github.com/ppy/osu-framework/pull/6610#discussion_r2199668728).
For clarity I'm not willing to review this further until I get buy-in from @ppy/team-client that everyone is fine with dropdowns changing UX on the fly depending on whether they're inside a scroll or not (#6610 (comment)).
I'm fine with this as a UX behaviour. As for implementation, we may want to consider making it automatic via inferring a parent scroll container?
https://github.com/ppy/osu-framework/blob/81663545601e0f9dcea461223163354ce2f3c0ca/osu.Framework/Graphics/Containers/ScrollContainer.cs#L193-L196
As for implementation, we may want to consider making it automatic via inferring a parent scroll container?
https://github.com/user-attachments/assets/5ac0904d-2f72-42b9-ac39-4d2f7c9817b8
Looks like this.FindClosestParent<IScrollContainer>() is doing wonders! No changes outside the framework are needed.
I've checked most of the places where dropdown menus are used in osu! and all look great, although editor's top bar is scrollable and its menus will therefore open on click – I guess it's fine anyways. Added a test with dropdown in a scrollable parent as well.
The only edge case for this behaviour is when dropdown header is moved somewhere from cursor. This is the unwanted UX change bdach was concerned about. In my defense, I would say this is rare (not present anywhere in osu! at least) and I would consider fixing the layout or just implicitly setting Dropdown.ToggleOnMouseDown to false.
https://github.com/user-attachments/assets/82da633c-e210-4e20-8b48-bf0eb16a297d