Hello,
I am testing the MenuModel and ListModel widgets. I wanted to create a popup menu and then set it with the ListModel >> menu: method. It runs right but once the listmodel open, when i right click on one item to see the pop-up menu it gives me the error as in the "#error.png" picture. Here is my example test (based on not significant data): [ menu := MenuModel new. menu addGroup: [ :group | group addItem: [ :item | item name: 'item1'; icon: (self iconNamed: #nautilus); action: [ anyAction1 ]]]; addGroup: [ :group | group addItem: [ :item | item name: 'item2'; icon: (self iconNamed: #smallSaveAs); action: [ anyAction2 ]]]; addGroup: [ :group | group addItem: [ :item | item name: 'item3'; icon: (self iconNamed: #smallAuthoringTools); action: [ anyAction4 ]]]. ll := LinkedList new. ll add: 'value1'; add: 'value2'; add: 'value3'; add: 'value4'; add: 'value5'; yourself. lm := ListModel new. lm items: ll; title: 'ListModel Menu Test'. lm menu:menu. lm openWithSpec. ] I get that the #cull:cull: message is not understood by my instance of MenuModel but i simply call the #menu: method defined in ListModel. Any ideas on the problem ? #error.PNG (300K) Download Attachment |
I did it perfectly with a toolbar. Jonathan 2017-04-03 16:16 GMT+02:00 Jonathan Khalil <[hidden email]>:
|
Hi Jonathan, If you check users of MenuModel and ListModel in the image, you get a few results that could give you an idea of how to do it. For example: If you look for users of MenuModel you arrive to EpSelection>>filtersSubMenu, which will lead you to EpSelection>>populateMenu: aMenu. And this leads you to: EpSelection >> initializeItemsModel itemsModel multiSelection: true; displayBlock: [ :item | item asMorph ]; childrenBlock: [ :item | self childrenItemsOf: item ]; whenSelectedItemsChanged: [ :selectedItems | self refreshEntryContentModelWith: selectedItems. itemsModel menu: [ :aMenu | self selection populateMenu: aMenu ] ]. So apparently, the method #menu: receives a block with a menu as argument, and you have to populate it with elements. Another way to arrive to the same conclusion is to look for senders of #menu:. There you see for example: ChangeSorterApplication >> initializeWidgets ... methodsListModel menu: [:menu :shifted | self messageMenu: menu shifted: shifted ]. changesListModel menu: [:aMenu :shifted | self changeSetMenu: aMenu shifted: shifted ]. classesListModel menu: [:aMenu :shifted | self classMenu: aMenu shifted: shifted ]. ... Cheers, Guille On Mon, Apr 3, 2017 at 6:44 PM, Jonathan Khalil <[hidden email]> wrote:
|
Free forum by Nabble | Edit this page |