Hi Sven,
Subject: [Pharo-users] How to add a contextual menu to a Spec
	ListModel
Message-ID: <5BBF6BCB-2C95-4948-932C-D14F71C0B3D9@stfx.eu>
Content-Type: text/plain; charset=us-ascii

Hi,

I am struggle a bit in find the right way to add a contextual menu to a Spec ListModel.

Consider:

ListModel new 
  title: 'List Example';
  items: Smalltalk allClasses; 
  openWithSpec.

I would like to add a right-click contextual menu to the list, with for example a 'Browse' action. I can't find such a simple example. I know there is a #menu: option, I can see some usages in my image, but they seem to do different things. What would be the recommended approach ?

ListModel new 
  title: 'List Example';
  items: Smalltalk allClasses; 
  "menu: [ ];"
  openWithSpec.

Thanks,

Sven

PS: Probably the reference to the #selectedItem of the ListModel for the action is hard to write in a one-liner, that is not a requirement.

I found the following to work for ListModel and MultiColumnList,
e.g to add #inspect as a list item pop up :

�� �menu: [ :m | self listMenu: m ] .

listMenu: m
�� �| item |
�� �item := m add: #inspect target: self selectedItem selector: #inspect .
�� �item enablementSelector: [ self selectedItem isNotNil ] .
�� �^m

Hartmut
--
signatur

Hartmut Krasemann
K�nigsberger Str. 41 c
D 22869 Schenefeld
Tel. 040.8307097
Mobil 0171.6451283
Krasemann@acm.org