Get selected text from textArea
Hi,
Anyone knows how to get the selected text from textArea?
I found the "selected" event from textArea, but how to use it? and is this usefull?
7 Answers
-
Accepted Answer
This is straight from the docs… pretty self explanatory… (use the range property in the event object)
selected
fired when the text in the field is selected
Event propertiesrange
the range of text. range is an object with the properties "location" and "length".
source the source object that fired the event
type the name of the event fired -
Do you mean 'selected' as in when a user uses the copy/paste select functions with an iphone? (with those draggable 'bars')
If so, no idea.
Or do you mean when the textarea has 'focus'?
-
Kosso
Yeah! like select words to copy/paste!
I need to get the selected word and save on database.
I think theres no difficulty to do this, but i dont know how :D -
Thanks all for the help given
I dont know how I've not did it before, but now is done!
I used this simple code:txtTeste.value.substr(e.range.location, e.range.length);
-
Hi guys, how to use selected event in textarea , i want to get selected text from textarea can you pls tell the sample example for this one….
-
Hello altogether,
i work with SDK 1.8.2 and simulator with iOS5. I will use the listener "selected" at a textarea. Source:
txtAction.addEventListener('selected', function(e) { Ti.API.info("Hello"); });
After a selection a crash comes:
[ERROR] application raised an exception. -[TiRange boundBridge:withKrollObject:]: unrecognized selector sent to instance 0xaea8b60
I will get a selection for detect the cursorposition. Is there a better way for do this? Thanks
-
This Bug is fixed.