[whatwg] Standard method to get/set caret position

On Mon, 30 Aug 2004, martijn wrote:
> >
> > Sadly the Mozilla APIs you used in your example aren't perfect either -- the
> > cursor could be at either selectionStart or selectionEnd, you don't really
> > have a way of knowing.
> It seems to me that the selection is the position of the cursor, not? When you
> press the left arrow key, the selection collapses and the cursor is at the
> start of where the selection was. With the right arrow key, the selection
> collapses and the cursor is at the end of where the selection was. Why should
> there also be a caret?

That describes the behaviour on some, but not all, platforms.

> > DOM Range could be used to define the selection of the document but 
> > that wouldn't work for selections in input and textarea elements since 
> > those don't have DOM nodes they correspond to. We could define that 
> > they do but that's quite a big change.
> I would certainly be in favor of that, because I like the range document 
> object model. I think the change that would be necessary is that typing 
> text inside text inputs and textareas should change the corresponding 
> value attribute and for the textarea the textnode inside the textarea.

There's no way we're going to change that. That'd never be backwards 
compatible. :-)

> > Mozilla's window.getSelection() method doesn't actually return a DOM 
> > Range, it returns some custom interface.
> Yes, it holds a collection of all the ranges you have added to the 
> selection object. so i't possible to have multiple selections in one 
> document.


> > So I don't know. What do people think? Should we try to be backards 
> > compatible with the Mozilla interface or the IE interface, or should 
> > we start from scratch here, and require that people write wrappers 
> > around the Moz and IE wrappers if they want compatibility? If we use 
> > something already defined, what do we use? What are the use cases that 
> > matter?
> I'm in favor of the Mozilla interface.

That's my current inclination too (just so I can avoid more headaches 
from reading MSDN's description of selections...).

Ian Hickson               U+1047E                )\._.,--....,'``.    fL
http://ln.hixie.ch/       U+263A                /,   _.. \   _\  ;`._ ,.
Things that are impossible just take longer.   `._.-(,_..'--(,_..'`-.;.'

Received on Friday, 12 November 2004 08:01:11 UTC