IBM
06-19-2004, 07:06 AM
*sigh*...
Well, I'd like to say I fully understand the range object..but I don't.
At the moment I'm having trouble figuring out how to get a selection using mousedown and mouseup. I can't use the selection object, it won't work in opera.. at least not in the examples I came across.
So my theory was to use the range object for selections use mouse events.
At the moment I have a pitiful theory for a function that will be called on window.load.
It should essentially capture onmousedown and then set the start of the range, then onmouseup set the range end. The problem is, if I understand setStart() and setEnd() properly, they require paramaters..but I don't know what paramters to pass setStart and setEnd.
Ok, what do you guys think about something like:
1) add mousedown and mouseup event handlers to the textarea
maybe something like textarea.addEventListener("mousedown"); etc.
2) On mousedown create a range, setStart(this.mousedown);
//at this point it's guess work for me, I'm not sure how to tell the range
//to start at the mousedown position. I'm not sure what paramater to pass.
3) On mouseup end the range, setEnd(this.mouseup);
//Same thing goes for this part of the script,
//I'm not sure how to tell the range to end at the mouseup position.
4) Use startContainer to make sure actions can only be performed when the
parent container is a textarea.
//I'm guessing this part won't be to difficult, I just hope most browsers
//understand startContainer();.
5) If it was as easy as pseudo code I'd be done by now.. :D
Any help is appreciated...
At the moment I'm just kind of stuck.. don't know where to go from here. And everywhere I look browser compatibility is a big issue. I had hoped to use the selection object.. too bad opera doesn't like it... :confused:
Well, I'd like to say I fully understand the range object..but I don't.
At the moment I'm having trouble figuring out how to get a selection using mousedown and mouseup. I can't use the selection object, it won't work in opera.. at least not in the examples I came across.
So my theory was to use the range object for selections use mouse events.
At the moment I have a pitiful theory for a function that will be called on window.load.
It should essentially capture onmousedown and then set the start of the range, then onmouseup set the range end. The problem is, if I understand setStart() and setEnd() properly, they require paramaters..but I don't know what paramters to pass setStart and setEnd.
Ok, what do you guys think about something like:
1) add mousedown and mouseup event handlers to the textarea
maybe something like textarea.addEventListener("mousedown"); etc.
2) On mousedown create a range, setStart(this.mousedown);
//at this point it's guess work for me, I'm not sure how to tell the range
//to start at the mousedown position. I'm not sure what paramater to pass.
3) On mouseup end the range, setEnd(this.mouseup);
//Same thing goes for this part of the script,
//I'm not sure how to tell the range to end at the mouseup position.
4) Use startContainer to make sure actions can only be performed when the
parent container is a textarea.
//I'm guessing this part won't be to difficult, I just hope most browsers
//understand startContainer();.
5) If it was as easy as pseudo code I'd be done by now.. :D
Any help is appreciated...
At the moment I'm just kind of stuck.. don't know where to go from here. And everywhere I look browser compatibility is a big issue. I had hoped to use the selection object.. too bad opera doesn't like it... :confused: