Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a way to make Drawable clicks not change focus #6297

Merged
merged 1 commit into from
May 22, 2024

Conversation

smoogipoo
Copy link
Contributor

RFC. This is useful in situations like the osu!-side collection dropdown, which expects to remain open when the add/remove button is pressed.

Master:

2024-05-23.00-14-01.mp4

With this PR (+ diff below):

2024-05-23.00-14-45.mp4
diff --git a/osu.Game/Collections/CollectionDropdown.cs b/osu.Game/Collections/CollectionDropdown.cs
index 15dd644073..c04689b097 100644
--- a/osu.Game/Collections/CollectionDropdown.cs
+++ b/osu.Game/Collections/CollectionDropdown.cs
@@ -202,7 +202,7 @@ public CollectionDropdownDrawableMenuItem(MenuItem item)
             [BackgroundDependencyLoader]
             private void load()
             {
-                AddInternal(addOrRemoveButton = new IconButton
+                AddInternal(addOrRemoveButton = new NoFocusChangeIconButton
                 {
                     Anchor = Anchor.CentreRight,
                     Origin = Anchor.CentreRight,
@@ -271,6 +271,11 @@ private void addOrRemove()
             }

             protected override Drawable CreateContent() => (Content)base.CreateContent();
+
+            private partial class NoFocusChangeIconButton : IconButton
+            {
+                public override bool ChangeFocusOnClick => false;
+            }
         }
     }
 }

Copy link
Sponsor Member

@peppy peppy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i guess this works

@peppy peppy merged commit a21df55 into ppy:master May 22, 2024
21 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants