Hi John,

many, many thanks for your ideas!
So maybe you are interested in the latest version where I implemented
the "cursor to new text" suggestion. Just pass true to
replaceSelection() as a second parameter. Or maybe it should be the default?

The latest testing version is is 0.2.1, but please note, it is not very
well tested in Opera and Safari. Also there are known IE quirks!

http://laboratorium.0xab.cd/jquery/fieldselection/

Also new is setSelection() which.. let's you set a field selection. :)
But please note: although it basically works, I for sure have to rewrite
the arguments stuff which is way too hackish. But what I wanted to
implement is stuff like this:

setSelection([2, 5])
setSelection({start: 5, end: 'current'})
setSelection({pos: 5})
setSelection('$') // cursor to end

I also want to implement things like "select word under cursor" and
similar things.

And I thought about optionally passing a function e.g. to intercept
replaceSelection(). This way you could easily implement stuff like
additionally wrap spaces around the inserted text, but only if there are
non surrounding, if you know what I mean.

So.. am I moving it into the right direction? :)

Alex


John Resig wrote:
> Ok, this is really really impressive. Every time that I have to deal
> with text-field selection, I'm constantly banging my head against the
> keyboard. This is a fantastic plugin to have on hand.
> 
> Some quick suggestions:
> - When you replace a snippet, the cursor loses focus. It would be
> fantastic if the new replaced snippet was selected too.  Like so: foo
> [bar] baz becomes: foo [zoo] baz (where [] is the selection)
> - In the object that you return, including two other properties:
> before (The text before the current selection) and after (the text
> after the current selection)
> - Make it so that you can bind a .selection() event (or some such) so
> that you can have a method be called back every time the selection
> changes, for example:
> $(...).selection(function(e,s){
>    alert( s.text );
> });
> (This would only have to fire whenever the selection is complete)
> 
> This is a great plugin - I can't wait to use it! (Especially
> considering that it works great in IE, Safari and Firefox!)
> 
> --John


_______________________________________________
jQuery mailing list
discuss@jquery.com
http://jquery.com/discuss/

Reply via email to