kando icon indicating copy to clipboard operation
kando copied to clipboard

Cycle through matching menus

Open Schneegans opened this issue 9 months ago • 5 comments

Description

Currently, if multiple menus are bound to the same shortcut, simply the first is opened. We could modify this in such a way, that pressing the same shortcut again while the menu is opened will bring up the next matching menu. Then, when you select something and press the shortcut again, the latest menu will be shown.

This would allow having multiple menus bound to the same hotkey and quickly switch between them.

Affected Desktop Environments

All

Additional Information

No response

Schneegans avatar Mar 28 '25 08:03 Schneegans

I can start working on this sometime this week.

I'm guessing I should look somewhere around here?

jonthemonke avatar Mar 31 '25 15:03 jonthemonke

I think this could be something for the separate settings branch as the menu-choosing code is now in a different file.

The main difficulty will be that currently the shortcuts are unbound when a menu is opened (here). This is primarily for single-key turbo mode:

  • Bind a menu to a single key, let's say F3.
  • Press this and keep it pressed. The menu pops up and you can move your mouse around as if the left mouse button was pressed. As soon as you release F3, the currently dragged item is selected. This only works because F3 is unbound when the menu is shown and Kando receives key-repeat events as long as the key is kept pressed.

So I am not sure how to properly model the interaction here. Maybe we would need to differentiate between a short press of the shortcut to switch to the next menu and a long press to enter turbo mode?

There is also this loosely related feature request: https://github.com/kando-menu/kando/issues/680

We should also keep this in mind, but maybe implementing everything is simply not possible... What we definitely do not want that the menu seemingly randomly disappears when the user wants to select something 😄

Schneegans avatar Mar 31 '25 16:03 Schneegans

Also, it has been requested multiple times that pressing the menu shortcut again after opening a menu should close it again. So maybe that would even require a setting so that the user can choose what happens when pressing the shortcut again while the menu is shown...

Schneegans avatar Apr 01 '25 07:04 Schneegans

In discord came up the idea of using the mouse wheel for switching through matching menus. I am not a real fan of that idea because it will neither work with pens or touch, but we could keep it in mind...

Schneegans avatar Apr 02 '25 19:04 Schneegans

I started building something rudimentary for this and I have found it confirms your previous statements. It will require quite a bit of thought in terms of settings to define the behavior and also like you previously mentioned, some thought into single-key turbo mode.

For behavior settings I think we could do something like sameShortcutBehavior with values of cycle or close and maybe first (to maintain the current behavior).

Currently, the cycling implementation is achieved by finding the next menu with the same shortcut and binding it once the current menu shortcut has been unbound but as you can see in the video, holding the shortcut results in this infinite loop ha-ha. I think I will have to think about the logic just a bit more.

https://github.com/user-attachments/assets/80d3f894-09a8-484c-9255-3074be23a652

jonthemonke avatar Apr 02 '25 20:04 jonthemonke

I think it works quite decently now. It would be cool if you could test it! Thanks for contributing to this feature, @jonthemonke!

Schneegans avatar Jun 14 '25 15:06 Schneegans

I think it works quite decently now. It would be cool if you could test it! Thanks for contributing to this feature, @jonthemonke!

No worries! Thanks for cleaning it up, sorry I have been so busy with other stuff recently. I should be able to test sometime this weekend!

jonthemonke avatar Jun 14 '25 15:06 jonthemonke