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

Web and WebWorks Development

Reply
New Developer
wslfung
Posts: 23
Registered: ‎08-29-2012
My Device: Dev Alpha
Accepted Solution

bb10 context menu

Hi

 

Can anyone tell me how the context menu works in bb10 or point me to some documentation.  I can't quite figure it out by just looking at the API reference.

 

 

Wilson

BlackBerry Development Advisor
Nukul
Posts: 115
Registered: ‎06-06-2011
My Device: 9800

Re: bb10 context menu

Context menus are enabled by default on a WebWorks applications.
Simply long press on a image or text and you should see the context menu.

Menu has many platform defined actions for each type but it also provides the developer to ability to add new items for each type. So if you look at the API examples it allows you add an item for Image type

function addMyItem() {
var myItem = {actionId: 'MyItem', label: 'My Item', icon:'http://mysite.com/icon.png'},
contexts = [blackberry.ui.contextmenu.CONTEXT_IMAGE, blackberry.ui.contextmenu.CONTEXT_INPUT];
blackberry.ui.contextmenu.addItem(contexts, myItem);
}

 

 

 

Soon you will be define custom context as well
https://github.com/blackberry/BB10-WebWorks-Framework/issues/184

@nukulb
New Developer
wslfung
Posts: 23
Registered: ‎08-29-2012
My Device: Dev Alpha

Re: bb10 context menu

I tried using CONTEXT_ALL, or CONTEXT_LINK and CONTEXT_IMAGE, adding the item ondomready, yet I can't get the context menu by long pressing, the only context menu I get is while using web inspector and it'll ask me if I want to inspect element.

would it have something to do with me using bbui?
BlackBerry Development Advisor
Nukul
Posts: 115
Registered: ‎06-06-2011
My Device: 9800

Re: bb10 context menu

if bbui is listening to the context menu event and preventing default, its going to trump and prevent the native context menu from showing.

Create a hello world WebWorks app with an image and then long press it. That will confirm that bbui is interfering and then you can open an issue with bbui
I am sure it will be fixed quickly if that infact is the problem
@nukulb
Developer
rorybarnes
Posts: 214
Registered: ‎01-07-2011
My Device: Bold 9900

Re: bb10 context menu

I don't think bbUI is listening for the context menu yet it currently just creates its own. There is an issue open to change that (https://github.com/blackberry/bbUI.js/issues/233).

 

If you long hold an image within bbUI it brings up the system context menu, if you setup your own context menu within bbUI it will show that when it is supposed to as well.

 

I supposed there could be a conflict if you add your own context menu to an image - that is the one piece I haven't tried it yet.

--
Rory (@roryboy)
Click "Accept as Solution" if post solved your original issue. Give like/thumbs up if you feel post is helpful
BlackBerry Development Advisor
chadtatro
Posts: 620
Registered: ‎10-01-2009
My Device: Z10

Re: bb10 context menu

We actually just released a sample app for Context Menu's last week on our GitHub repo which you could use for reference.

 

https://github.com/blackberry/BB10-WebWorks-Samples/tree/master/contextmenu

Chad Tetreault | App Development Consultant | BlackBerry Developer Relations | developer.blackberry.com | @chadtatro
Developer
splatterb0y
Posts: 18
Registered: ‎12-15-2012
My Device: Z10 LE, Playbook and Dev Alpha C

Re: bb10 context menu

Is it possbile to disable the context menu in webworks?

 

Because people should now be able to just tap and hold on images within my app and save them. 

Developer
interfaSys
Posts: 817
Registered: ‎11-19-2009
My Device: Z10, Q10, 9900, 9790, PlayBook,

Re: bb10 context menu

It's disabled by default. You need to ask for it in config.xml

--
Olivier - interfaSys ltd
Developing for BlackBerry 10 devices using the Sencha Touch framework.
Developer
splatterb0y
Posts: 18
Registered: ‎12-15-2012
My Device: Z10 LE, Playbook and Dev Alpha C

Re: bb10 context menu

Can you please describe what you mean with "You need to ask for it in config.xml"?

Developer
interfaSys
Posts: 817
Registered: ‎11-19-2009
My Device: Z10, Q10, 9900, 9790, PlayBook,

Re: bb10 context menu

You need to add the feature to your config.xml, like this

<feature id="blackberry.ui.contextmenu" />

--
Olivier - interfaSys ltd
Developing for BlackBerry 10 devices using the Sencha Touch framework.