04-19-2011 10:32 PM
Anyone else having issues getting event.preventDefault working properly on the tablet simulator?
I've placed event.preventDefault() on all touch and mouse events, (onmouseup, onmousedown, onmousemove, ontouchstart, ontouchend and on touchmove). For example:
But I can still easily make the document scroll.
(I'm working with the latest SDK and simulator)
04-20-2011 12:51 AM
Perhaps this is a silly question but why would you override the mouse events as well as touch?
Anyway - the following definitely works
[rest of the code to handle touch events]
document.addEventListener("touchstart", touchHandler, true);
document.addEventListener("touchmove", touchHandler, true);
document.addEventListener("touchend", touchHandler, true);
document.addEventListener("touchcancel", touchHandler, true);
This locks your app so you can't drag it around unless you tell it to in the handler code via something alonf the lines of
var simulatedEvent = document.createEvent("MouseEvent");
simulatedEvent.initMouseEvent(type, true, true, window, 1,
first.clientX, first.clientY, false,
false, false, false, 0, null);
An example of this kind of selective processing of events can be found in the sketchpad example
04-20-2011 09:03 AM
04-24-2011 07:35 AM
Can you please confirm that you guys got that figured out?
in terms of the scrolling stage, my app was working fine on the tablet SDK a few weeks ago WITHOUT the assistance of event.preventDefault. i was able to properly drag an element of my app around the screen. the main fix was to make the body was smaller than the screen size, and everything stayed in place while i dragged the target element. now i updated the SDK, and all of the sudden the stage would stay still. i can't drag anything without taking the whole app stage with it. I tried the event.preventDefault and the stopPropagation. i suspect that this change is due to new "design feature" in the tablet SDK. hopefull it is not so on the actual tablet, as it is quite unwanted in this case.
I tried the recommendations of peardox, as I understood it, but that did not work
I've also tried the simplest HTML with a single box of 200x200 pixels. and body size of 500x400 (confirmed with borders). even still, normal use of preventDefault or stopPropagation would not keep the stage from scrolling vertically.
04-24-2011 08:22 AM