Open koendehondt opened 1 month ago
@estebanlm Please respond to this question because it blocks finalising the book. Thank you!
I'd say is a bug, yes
Thank you for the confirmation. Tonight, I will create a PR for Pharo 12.
@estebanlm Here is the PR for Pharo 12: https://github.com/pharo-spec/Spec/pull/1621. Please merge as soon as possible because the fix is required for the Spec book. Thank you!
@estebanlm, cc @Ducasse
Context: Spec book, Pharo 12, creating a toolbar based on commands.
Question 1
When using code like this in my presenter:
I noticed that the button enablement is not correct.
When digging into it, I read the method
SpCommand>>#configureAsButtonOfClass:
, implemented as:#enabled:
is not sent to the button presenter. Consequently, the created button presenter is enabled, even if sending#canBeExecuted
tospecCommand
would answerfalse
.Isn't that a bug? I would say it is. I think the code above should be (see the addition of
enabled: specCommand canBeExecuted;
):If you agree, I will create a PR.
Question 2
The implementation above has another disadvantage, even if the above issue is not a bug. What is the prescribed way to enable/disable toolbar buttons after creating the toolbar with
SpToolbarPresenter>>#fillWith:
?Because the toolbar buttons are created by
SpToolbarPresenter>>#fillWith:
, they cannot be held in instance variables in a presenter. Therefore they cannot be enabled/disabled easily when the state of the application changes. One could re-fill the toolbar withSpToolbarPresenter>>#fillWith:
, but then the button enablement is not correct, as described in question 1.Please explain how to update toolbar buttons with the correct enablement when the state of the toolbar's presenter changes. Thank you.