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

Consider renaming MenuItem.when to MenuItem.visible #225

Open
jni opened this issue Nov 26, 2024 · 2 comments
Open

Consider renaming MenuItem.when to MenuItem.visible #225

jni opened this issue Nov 26, 2024 · 2 comments

Comments

@jni
Copy link

jni commented Nov 26, 2024

  • app-model version: 0.3.0
  • Python version: 3.11
  • Operating System: macOS

Description

While working on napari/napari#5483, @DragaDoncila, @lucyleeow and I got a bit confused about the usage of MenuItem.when vs CommandRule.enablement. I think that's because "when" really needs a "when what": it could just as easily mean "when is it enabled", or "when is it highlighted". In fact it means when is it visible. So we are thinking it may be nice to rename it to visible, visibility, when_visible, ... or similar.

Any thoughts @tlambert03? Obviously the deprecation would be annoying but even medium term I think it would make app-model usage more intuitive.

@tlambert03
Copy link
Member

I don't know, pretty much everything about menu rules is about visibility, so to me it feels a bit repetitive. There is nothing in menus that has to do with enablement of the command that the menu item represents... since that is a command related feature. That is, menus determine where to show a command (just like toolbars do), but whether it's ok to invoke the command (enablement) is always a property of the command (and not a property of where you've chosen to place that command).

I see that you were confused, so that's worth something for sure... but once you think of everything about menus as "where and when to put a view of a command" and everything about commands to be "what and whether it's enabled" (but not where they are placed), do you still think it's worth the deprecation process?

You guys look at it more than I do, so if it's a thought you or other devs have had more than once, I'm happy to change it for you

@jni
Copy link
Author

jni commented Nov 26, 2024

Thanks, good writeup. We can stew on this a bit longer, it is potentially just a case of me getting to know my own codebase. 😅 I still see value in making it more verbose (other people will also be newbies in our codebase, for all time), but let's play with it more before taking the leap.

Also @DragaDoncila and @lucyleeow want me to clarify that I besmirched their good name because only I was confused about what "when" did, they were just confused about when it is appropriate to use which of the two, from a UX standpoint. 😂

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

2 participants