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
Highlighted
Developer
Posts: 166
Registered: ‎02-15-2012
My Device: Playbook 16GB
My Carrier: Bags are useful

Disable Context Menu

Is there anyway to disable the context menu that pops up when you press and hold an image in Blackberry 10? Im using bbUi.js and was wondering if that is possible.

If any post helps you please click the Like Button below the post(s) that helped you.
2. Please resolve your thread by marking the post "Solution?" which solved it for you!

BlackBerry Development Advisor
Posts: 757
Registered: ‎10-01-2009
My Device: All
My Carrier: N/A

Re: Disable Context Menu

This thread should help get you in the right direction.  I believe that you're basically capturing the touch event, then preventDefault(); which stops the default behavior of said event from firing.

 

http://supportforums.blackberry.com/t5/Web-and-WebWorks-Development/Disable-context-menu-on-taphold/...

Developer
Posts: 166
Registered: ‎02-15-2012
My Device: Playbook 16GB
My Carrier: Bags are useful

Re: Disable Context Menu

Im using bbUi.js so I have to load scripts externally. Also, Im using a table with Images and Im not sure exactly how to implement that coding you provided.

<table width="100%">
  <tr>
    <td><img src="images/n1.png" height="266px" width="204px" onclick="blackberry.system.setWallpaper('local:///images/n1.png');"/></td>
    <td><img src="images/n2.png" height="266px" width="204px" onclick="blackberry.system.setWallpaper('local:///images/n2.png');"/></td>
    <td><img src="images/n3.png" height="266px" width="204px" onclick="blackberry.system.setWallpaper('local:///images/n3.png');"/></td>
</tr>
</table>

 Thanks for your help

 

 

If any post helps you please click the Like Button below the post(s) that helped you.
2. Please resolve your thread by marking the post "Solution?" which solved it for you!

Retired
Posts: 245
Registered: ‎09-21-2012
My Device: Q10
My Carrier: Virgin

Re: Disable Context Menu

You have 2 options to prevent it:

window.oncontextmenu = function (evt) {
    evt.preventDefault();
}
OR You will need to include local:///chrome/webworks.js in your app as well as the feature blackberry.ui.contextmenu adn then you can do the following:
blackberry.ui.contextmenu.enabled = false;
@erikjohnzon
erjohnson@blackberry.com