Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Native Development

Reply
Highlighted
Developer
Posts: 144
Registered: ‎12-18-2010
My Device: Limited Edition Z10 & Blackberry Playbook
My Carrier: Rogers Wireless

ListView ContextMenu problems

Hi All,

 

In my app DictaNoteI currently have a ListView that displays all the recordings that the user has made.  I have a bunch of context actions that are possible on those recordings.  Originally I set up the ListView like so:

ListView {
    id: list
    dataModel: app.model
                
    listItemComponents: [

                    // define delegates for different item types here
         ListItemComponent {
        // StandardListItem is a convivience component for lists with default cascades look and feel
                StandardListItem {
                     title: ListItemData.displayname
                }
           }
         ]
         contextActions: [
              ActionSet {
                  actions: [
                      ActionItem {
                         id: action1
                         
                         title: qsTr("Action 1")
                         imageSource: "action1.png"
                         onTriggered: {
                              // Do Stuff here
                         }
                     }
                  ]
              }
         ]
}

 

But then I noticed that this context menu will show up if I long press on a blank area of the ListView, which makes sense since the menu is on the ListView and not the ListItem.  So I looked a a couple samples and noticed that they have the context menu specified as part of the ListItem.   So I tried changing me definition of the ListItemComponent to be like so:

 // Override default GroupDataModel::itemType() behaviour, which is to return item type "header"
                listItemComponents: [

                    // define delegates for different item types here
                    ListItemComponent {
                        // StandardListItem is a convivience component for lists with default cascades look and feel
                        StandardListItem {
                            title: ListItemData.displayname
                            //description: ListItemData.filesize
                            contextActions: [
                                 ActionSet {
                                    ActionItem {
                                       // Actual item details here
                                    }

                                 }

                            ]
                        }
                    }
                ]

 

This did not work and caused my menu to not show when I long pressed the item in the list.  Does anyone see anything wrong with what I've done?  I looked over the samples several times and don't see what the difference is but maybe I'm overlooking something.  Let me know if you need more code to get a better idea of what is going on.

 

P.S - sorry for bad formatting in the code snippits,  it pasted in weird from the IDE.

 

Thanks,

 

 

 

 

Playbook Apps:
Touch Painter, LinkShrink

BB10 Apps:
NoteToSelf , LinkShrink