[Seaside] Textarea and setSelectionRange()

Sebastian Sastre ssastre at seaswork.com
Mon Mar 16 13:15:47 UTC 2009


yes, the hard part is when you want the caret position in pixels as I need now.
Looks like there is no cross browser solution for that yet :/
sebastian 

> -----Mensaje original-----
> De: seaside-bounces at lists.squeakfoundation.org 
> [mailto:seaside-bounces at lists.squeakfoundation.org] En nombre 
> de Bany, Michel
> Enviado el: Monday, March 16, 2009 04:26
> Para: Seaside - general discussion
> Asunto: RE: [Seaside] Textarea and setSelectionRange()
> 
> Support for this is available in Seaside 2.8.
> 
> See #setSelectionFrom:to: and WAStandardFiles>>miscJs.
> See also #renderTextArea: for an example.
> 
> HTH,
> Michel
> 
> 
> 
> 
> > -----Original Message-----
> > From: seaside-bounces at lists.squeakfoundation.org 
> > [mailto:seaside-bounces at lists.squeakfoundation.org] On Behalf 
> > Of Lukas Renggli
> > Sent: samedi, 14. mars 2009 17:25
> > To: Seaside - general discussion
> > Subject: Re: [Seaside] Textarea and setSelectionRange()
> > 
> > > Has anyone here managed to call the setSelectionRange() 
> > method against 
> > > a textarea in Seaside?  I cannot seem to get this working.
> > 
> > Text selection is handled different in IE.
> > 
> > There is JavaScript code in the Pier-EditorEnh plugin at 
> > <http://source.lukas-renggli.ch/pieraddons> that retrieves 
> > and sets the text selection. As far as I know this code works 
> > in all web
> > browsers:
> > 
> > function getSelection(element) {
> > 	if (document.selection && document.selection.createRange) {
> > 		var range = document.selection.createRange();
> > 		var stored = range.duplicate();
> > 		stored.moveToElementText(element);
> > 		stored.setEndPoint("EndToEnd", range);
> > 		element.selectionStart = stored.text.length - 
> > range.text.length;
> > 		element.selectionEnd = element.selectionStart + 
> > range.text.length;
> > 	}
> > 	return [element.selectionStart, element.selectionEnd]; }
> > 
> > function setSelection(element, range) {
> > 	element.focus();
> > 	element.selectionStart = range[0];
> > 	element.selectionEnd = range[1];
> > 	if (document.selection && document.selection.createRange) {
> > 		var range = document.selection.createRange();
> > 	 	range.moveStart("character", element.selectionStart);
> > 	    	range.moveEnd("character", element.selectionEnd 
> > - element.selectionStart);
> > 		range.select();
> > 	}
> > }
> > 
> > Cheers,
> > Lukas
> > 
> > --
> > Lukas Renggli
> > http://www.lukas-renggli.ch
> > _______________________________________________
> > seaside mailing list
> > seaside at lists.squeakfoundation.org
> > http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
> > 
> _______________________________________________
> seaside mailing list
> seaside at lists.squeakfoundation.org
> http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside



More information about the seaside mailing list