Hi Sven,
I found the following to work for ListModel and MultiColumnList,Subject: [Pharo-users] How to add a contextual menu to a Spec ListModel Message-ID: [hidden email] 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. 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 --
Hartmut Krasemann |
Hi Hartmut,
Thanks for the reply. Like I said in my previous post 'I like to stay within Spec as much as possible', it got it working fine now. Sven > On 24 May 2017, at 12:03, Hartmut Krasemann <[hidden email]> wrote: > > Hi Sven, >> Subject: [Pharo-users] How to add a contextual menu to a Spec >> ListModel >> Message-ID: >> <[hidden email]> >> >> 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 > -- > Hartmut Krasemann > Königsberger Str. 41 c > D 22869 Schenefeld > Tel. 040.8307097 > Mobil 0171.6451283 > [hidden email] |
Free forum by Nabble | Edit this page |