07-09-2011 11:02 PM
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?
Solved! Go to Solution.
07-11-2011 07:25 AM
Is this on PlayBook or on BB6?
07-11-2011 07:35 AM
Sorry.. this is on the PlayBook.
07-11-2011 08:43 AM
And this is in the Browser and not a WebWorks application correct?
07-11-2011 09:18 AM - edited 07-11-2011 09:18 AM
Hi Tim,
This is for an actual WebWorks app, that runs on the PlayBook. I'm using JavaScript and jQuery to code it.
07-12-2011 05:48 PM
Guessing nobody has the answer?
07-12-2011 05:51 PM
Can you post a screen shot to show the Menu items that are popping up?
07-12-2011 06:23 PM
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>
07-13-2011 09:31 AM
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>
07-21-2011 04:04 PM
Great example, works.
Thanks again Tim.