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

Bug: Menu item enablement in CmUICommandDisplayStrategy>>#display:in:do: is fixed #1603

Closed
koendehondt opened this issue Sep 15, 2024 · 0 comments

Comments

@koendehondt
Copy link
Contributor

Context : Pharo 12 and Pharo 13.

I think CmUICommandDisplayStrategy>>#display:in:do: is implemented incorrectly. Now it is:

display: aCmSpecCommand in: aMenuOrGroupPresenter do: aBlock
	aMenuOrGroupPresenter
		addItem: [ :item |
			aBlock value: item.
			item enabled: aCmSpecCommand canBeExecuted.
			item ]

As a consequence, a menu item's enablement state is set only once, when the menu item is added. Given that the command decides whether it can be executed, the enablement state should be updated every time a menu item is displayed. In Spec, that is achieved by passing a block to #enabled:.

So I think the method should be implemented as:

display: aCmSpecCommand in: aMenuOrGroupPresenter do: aBlock
	aMenuOrGroupPresenter
		addItem: [ :item |
			aBlock value: item.
			item enabled: [ aCmSpecCommand canBeExecuted ].
			item ]

This issue is related to #1559 and #1561, which report other enablement issues.

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

No branches or pull requests

2 participants