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
Contributor
rlowe
Posts: 29
Registered: ‎06-17-2010
My Device: Bold 9700
My Carrier: Wind
Accepted Solution

Disable context-menu on taphold.

Can't seem to stop the default 'context-menu' from popping up when I tap & hold on the screen.

 

I've tried using preventDefault in my taphold event, but it still pops up.

 

Any suggestions?

Please use plain text.
BlackBerry Development Advisor
tneil
Posts: 3,708
Registered: ‎10-16-2008
My Device: Z10
My Carrier: Rogers

Re: Disable context-menu on taphold.

Is this on PlayBook or on BB6?

Tim Neil
Director, Application Platform & Tools Product Management
Follow me on Twitter
Please use plain text.
Contributor
rlowe
Posts: 29
Registered: ‎06-17-2010
My Device: Bold 9700
My Carrier: Wind

Re: Disable context-menu on taphold.

Sorry..  this is on the PlayBook.

Please use plain text.
BlackBerry Development Advisor
tneil
Posts: 3,708
Registered: ‎10-16-2008
My Device: Z10
My Carrier: Rogers

Re: Disable context-menu on taphold.

And this is in the Browser and not a WebWorks application correct?

Tim Neil
Director, Application Platform & Tools Product Management
Follow me on Twitter
Please use plain text.
Contributor
rlowe
Posts: 29
Registered: ‎06-17-2010
My Device: Bold 9700
My Carrier: Wind

Re: Disable context-menu on taphold.

[ Edited ]

Hi Tim,

 

This is for an actual WebWorks app, that runs on the PlayBook.  I'm using JavaScript and jQuery to code it.

Please use plain text.
Contributor
rlowe
Posts: 29
Registered: ‎06-17-2010
My Device: Bold 9700
My Carrier: Wind

Re: Disable context-menu on taphold.

Guessing nobody has the answer? 

Please use plain text.
BlackBerry Development Advisor
tneil
Posts: 3,708
Registered: ‎10-16-2008
My Device: Z10
My Carrier: Rogers

Re: Disable context-menu on taphold.

Can you post a screen shot to show the Menu items that are popping up?

Tim Neil
Director, Application Platform & Tools Product Management
Follow me on Twitter
Please use plain text.
Contributor
rlowe
Posts: 29
Registered: ‎06-17-2010
My Device: Bold 9700
My Carrier: Wind

Re: Disable context-menu on taphold.

I'm not infront of the PlayBook at the moment, but I can tell you that it's the 'Copy' and 'Cancel' buttons, along with the two dragabble buttons that allow you to select text.

 

In my app, I have a table with several rows.  Each row contains text.  When you tap and hold on these table rows, the copy/cancel context menu appears after about a second.

 

As far as the html side of things, it's pretty basic layout.

 

<table>

<tr>

<td> <p> foobar </p> </td>

</tr>

</table>

 

 

Please use plain text.
BlackBerry Development Advisor
tneil
Posts: 3,708
Registered: ‎10-16-2008
My Device: Z10
My Carrier: Rogers

Re: Disable context-menu on taphold.

Below is some sample code provided by one of the developers here at RIM

 

<!DOCTYPE html>
<html lang="en">
    <head>
        <meta charset="utf-8">
        <meta name="viewport" content="width=device-width, height=device-height, initial-scale=1.0, user-scalable=no">
        <title>preventDefault</title>
        <link href="favicon.ico" rel="icon" type="image/x-icon">
        <style type="text/css">
        #trigger {
            border: 1px solid #CCC;
            border-radius: 10px;
            padding: 20px;
        }
        </style>
    </head>
    <body>
        <h1>preventDefault</h1>

        <div id="trigger">Tap and hold here.</div>

        <div id="result"></div>

        <script type="text/javascript">
        var app = {

        };

        app.touchStart = function (e) {
            e.preventDefault();

            app.touchX1 = e.targetTouches[0].pageX;
            app.touchY1 = e.targetTouches[0].pageY;
        };

        app.touchMove = function (e) {
            e.preventDefault();

            app.touchX2 = e.targetTouches[0].pageX;
            app.touchY2 = e.targetTouches[0].pageY;
        };

        app.touchEnd = function (e) {
            e.preventDefault();

            if (app.touchX1 && app.touchX2) {
                app.panX = app.touchX1 - app.touchX2;
                app.panY = app.touchY1 - app.touchY2;
                document.getElementById('result').innerHTML = '(' + app.touchX1 + ',' + app.touchY1 + ') => (' + app.touchX2 + ',' + app.touchY2 + ') = (' + app.panX + ',' + app.panY + ')';
            }
        };

        var elem = document.getElementById('trigger');

        elem.addEventListener('touchstart', app.touchStart, false);
        elem.addEventListener('touchmove', app.touchMove, false);
        elem.addEventListener('touchend', app.touchEnd, false);
        </script>
    </body>
</html>

 

Tim Neil
Director, Application Platform & Tools Product Management
Follow me on Twitter
Please use plain text.
Contributor
rlowe
Posts: 29
Registered: ‎06-17-2010
My Device: Bold 9700
My Carrier: Wind

Re: Disable context-menu on taphold.

Great example, works.

 

Thanks again Tim.

Please use plain text.