pharo-spec / Spec

Spec is a framework in Pharo for describing user interfaces.
MIT License
62 stars 63 forks source link

SpMenuPresenter>>#fromSpec: calling method removed in Pharo10 #1284

Closed JanBliznicenko closed 2 years ago

JanBliznicenko commented 2 years ago

Method SpMenuPresenter>>#addAllFromPragma:target: calls method SpMenuPresenter>>#fromSpec:. Neither is marked as TOREMOVE nor deprecated. However, this fromSpec: method calls SpMenuItemPresenter>>#fromSpec: that has been marked as TOREMOVE in Pharo 9 and has been removed in Pharo 10. Result is Instance of SpMenuItemPresenter did not understand #fromSpec:.

Is there any alternative or should it be fixed?

estebanlm commented 2 years ago

it is indeed removed. Solution is not use Specs (which are something made to do MenuMorphs) but direct presenters, which are, in a way, also "specs" :P

JanBliznicenko commented 2 years ago

Ok, then these methods like SpMenuPresenter>>#fromSpec: should be deprecated and removed as well, right? What about package MenuRegistration? I will probably create alternative to this (generating menu from pragmas) that would generate Spec2 menu-related instances instead of these Morhpic specs.

demarey commented 2 years ago

A nice way to define a menu in Spec 2 is to define commander 2 commands, add a asSpecCommand method on the commands. Then you define a Command group that contains commands of the menu. Last, you use contextMenuFromCommandsGroup: commandGroup on your presenter to set the context menu

JanBliznicenko commented 2 years ago

Thank you, @demarey, for your help - I am moving OpenPonk from Pharo 8-. Actually, it is not a context menu, but button on menu bar that opens menu with multiple menu groups (ie. menu with splitters):

obrazek

Is that (including menu groups) achievable with Commander2 as well?

demarey commented 2 years ago

Command 2 command groups can be easily added to any menu presenter. You should be able to define a group for diagram containing a first group with one command, a second group with 2 commands and the last one with 5 commands. Then, you can instantiate a SpMenuButtonPresenter and set its menu with #menu: diagramGroup asMenuPresenter

JanBliznicenko commented 2 years ago

Thank you very much, @demarey, your explanation helped me a lot.