2
votes

I'm using BlackBerry-10 Cascades to develop an app. I want a context menu to open on the right when I click a button. Currently I have it so that the menu opens after a press- hold of the button but I need it to open as soon as the button is tapped. I've tried finding a way to do this but cannot find it in the documentation. Is there any way I can invoke the context menu from the onclicked method of a button press?

BTW: this is all in QML

5
Can you paste the code you are using to open the context menu with a press-hold?hyarion

5 Answers

0
votes

I am not really familiar with the controls available on blackberry-cascades, but, it seems like it should be as simple as moving the code from the onPressAndHold signal handler to the onClicked signal handler. For better help you should post the relevant snippets of your code along with the imports so we can find more info to help you in your particular scenario.

0
votes
actions: [
        //! [0]
        ActionItem {
            title: _webMaps.viewModeTitle
            imageSource: "asset:///images/map.png"
            ActionBar.placement: ActionBarPlacement.OnBar
            onTriggered: {
                _webMaps.nextViewMode()
                map.setMapType(_webMaps.viewMode);
            }
        },
        //! [0]
        ActionItem {
            title: qsTr("Waterloo")
            imageSource: "asset:///images/pin.png"
            ActionBar.placement: ActionBarPlacement.InOverflow
            onTriggered: {
                map.setCenter(43.468245, -80.519603);
            }
        }
    ]

try this sample..

0
votes

In theory you should be able to do it but there are two problems that I see with this idea:

  1. A context menu is supposed to be posted in the context of another UI element. I'm not sure what context menu items you might have for a button. If you are posting the context menu in the context of some other control then you will confuse your users.
  2. The age old issue of non-conformance with the UI style guide of the platform. You will be expecting your uses, who have invested time in learning how to operate the BB10 UI, to now learn a different set of interface semantics.
0
votes

There is a Context menu api in the BlackBerry Platform Services (BPS) library that you can use.

https://developer.blackberry.com/native/reference/core/com.qnx.doc.bps.lib_ref/topic/manual/dialog.h_functionscontextmenufunctions.html?f=dialog

It is not "Cascades functionality" per se, but you can use it from within a Cascades application. Note that it is a C based api so you would have to create some kind of "helper class" and expose it to QML yourself.

0
votes

Try this sample code for open context menu on button clicked.