You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
#enabled: is not sent to the button presenter. Consequently, the created button presenter is enabled, even if sending #canBeExecuted to specCommand would answer false.
Isn't that a bug? I would say it is. I think the code above should be (see the addition of enabled: specCommand canBeExecuted;):
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 with SpToolbarPresenter>>#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.
The text was updated successfully, but these errors were encountered:
@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.
The text was updated successfully, but these errors were encountered: