If your context menu is defined through a block it means is dynamic, and it will be evaluated each time the context menu is invoked.
contextMenu: aValuableOrMenuPresenter
"Set the context menu.
Context menu can be an instace of `SpMenuPresenter` or a block (that will answer eventually an
instance of `SpMenuPresenter` aswell.
If your context menu is defined through a block it means is dynamic, and it will be evaluated
each time the context menu is invoked."
contextMenu := aValuableOrMenuPresenter
Look at SpTreePresenter class>>#exampleWithContextMenu
:
app := SpApplication new.
presenter := SpPresenter newApplication: app.
(tree := presenter newTree)
roots: { Object };
children: [ :aClass | aClass subclasses ];
displayIcon: [ :aClass | self iconNamed: aClass systemIconName ];
display: [ :aClass | aClass name ];
contextMenu: [
presenter newMenu
addGroup: [ :group | group
addItem: [ :item | item name: tree selectedItem asString ] ] ].
presenter layout: (SpBoxLayout newTopToBottom
add: tree;
yourself).
presenter open