beeware / toga

A Python native, OS native GUI toolkit.
https://toga.readthedocs.io/en/latest/
BSD 3-Clause "New" or "Revised" License
4.36k stars 674 forks source link

Add ability to create context menus for Widget #2895

Open hyuri opened 1 month ago

hyuri commented 1 month ago

What is the problem or limitation you are having?

Currently, Toga seems to provide no way for us to create context menus and associate them with certain widgets. This limits the potential to develop some more complex applications that might benefit from them — apps containing multiple panels that can be placed in different sides of the GUI, as an example, like image editors.

Describe the solution you'd like

Add ability to create context menus and assign them to certain widgets, like Boxes. It's especially useful because, since Toga doesn't provide drag and drop support yet, context menus can provide a way to add options such as "Move panel to the right/left" etc.

Describe alternatives you've considered

None

Additional context

No response

freakboy3742 commented 1 month ago

A reasonable request for desktop platforms; possibly with some internal overlap with #2210 (in that there's now a "scope" in which some commands are visible/available)

Some thought will need to be given to how this will manifest on mobile. There isn't really any analog of context menus on mobile; we need to be careful that we don't encourage a UX design pattern that could lead to commands being hidden from use.

The ultimate answer might end up be a straightforward "context menus are ignored on mobile"; but that needs to be a conscious decision, not an accidental one.