OK so I've got some news but it's mostly dreary. I have an iPhone simulator from an old SDK but it doesn't seem to support any kind of selection behavior. In order to get the "iOS Simulator" which apparently does iPad mode, I have to upgrade to Lion and to upgrade to Lion I have to first upgrade to Snow Leopard so I'm looking at about $70 in software upgrades for a computer I use to watch neftlix 🙁
The other dreary bit is that I've been searching around for touch-related event handling information and I can't seem to locate any that will reliably let me fire an event when the selection changes. When one holds a finger down on a DIV or P tag in my iPod Touch, a sort of selection mode is enabled but when I attempt to alter the selection start and end point, I don't seem to get more touchend events firing despite the fact I am touching the screen and altering the start/end points of my selection. I have so far tried the touchend event and will try touchmove in a bit. Some sample code:
<html>
<head>
<script type="text/javascript">
document.addEventListener('DOMContentLoaded', function() {
document.addEventListener('touchend', function(evt) {
var el = document.getElementById("log");
if (!el) {
alert('no log element');
}
el.innerHTML += log(evt);
var t = '';
if(window.getSelection){
t = window.getSelection();
}else if(document.getSelection){
t = document.getSelection();
}else if(document.selection){
t = document.selection.createRange().text;
}
var el2 = document.getElementById("destination");
if (!el2) {
alert('no dest element!');
return;
}
el2.value = t;
});
});
function log(obj) {
var res="";
for(var p in obj) {
res += "\n" + p + "=" + obj[p];
}
return res;
}
</script>
</head>
<body>
<p id="target">Here is a text paragraph. Here is a text paragraph. Here is a text paragraph. Here is a text paragraph. Here is a text paragraph. Here is a text paragraph. Here is a text
paragraph. Here is a text paragraph. Here is a text paragraph. Here is a text paragraph. Here is a text paragraph. Here is a text paragraph. Here is a text paragraph. Here
is a text paragraph. Here is a text paragraph. Here is a text paragraph. </p>
<textarea id="destination"></textarea>
<div id="log" style="font-size:1.5em;background-color:red;color:white;"></div>
</body>
</html>