I'm trying to create different context menus in QML, but I don't know what is the correct syntax for that. I would like to do something like:
contextActions: [
ActionSet {
title: "Action Set"
subtitle: "This is an action set."
actions: if (_corporate.currentView == 2) {
[ ActionItem { title: "Action 1" },
ActionItem { title: "Action 2" },
ActionItem { title: "Action 3" } ]
} else {
[ActionItem { title: "Action 4" },
ActionItem { title: "Action 5" },
ActionItem { title: "Action 6" }
]
}
} // end of ActionSet
] // end of contextActions list
That's obviously wrong syntax, so what is the correct way? Thanks in advance!
The correct way for me (enabling me to have different number of context menu items in different cases) is to use different elements which would be chosen from depending from the context.
In my case, I have a list in which I can have separate ListItemComponents
depending on the type of the data. I wasn't too specific when asking the question, sorry.
Here's the correct answer, with code samples: http://supportforums.blackberry.com/t5/Cascades-Development/Context-dependent-contextActions/td-p/2044783
What is missing there, is the example of usage of the DataModel::itemType()
function (crucial in this scenario), so here's an example of that: https://developer.blackberry.com/cascades/documentation/ui/lists/groupdatamodel.html