-
1. Re: Text Field - Get selected text
Steve L Walker Dec 21, 2010 1:57 PM (in response to past-tense)The text entered in to a Text Field object is available in the exit event as this.rawValue.
Steve
-
2. Re: Text Field - Get selected text
past-tense Dec 21, 2010 2:31 PM (in response to Steve L Walker)This only provides the full text of the text box... I was hoping to get the selected text...
Now, I know that the selected text is lost when the field loses focus, but I also know that the selected text remains selected until after the exit event fires fully.
To test this, thow an 'xfa.host.messageBox("is it still selected?")' into the exit event of a text box... Run the form, write a line, select a part of it, then exit the text box. You'll get an alert, and the text is still selected. The way I see it, this would be as good a time as any to get the selected text, I just need to know how.
I've tried several javascript methods, but they were all designed for web browsers. The only thing else that is similar that I can find is the selStart/selEnd attributes that get filled with the selection indexes on the change event. I'm just now looking at how these attributes work.
Does anyone know if it's possible to use these attributes to get the selected indexes on exit?
Thanks again for any help.
- Scott
-
3. Re: Text Field - Get selected text
Steve L Walker Dec 21, 2010 2:44 PM (in response to past-tense)This is not possible. What is the use case?
Steve
-
4. Re: Text Field - Get selected text
past-tense Dec 21, 2010 2:59 PM (in response to Steve L Walker)My users want to be able to select some text, press a button and have formatting applied to the selection. I know that adobe has some primitive formatting for rich text fields... bold, italics, font, color, etc... but they want all of these buttons incorporated on the form itself. Also, there are some custom effects that my users want... as in bullets, lists, tabs, etc.
I'm still playing with the selStart/End... but no luck yet,
- Scott
-
5. Re: Text Field - Get selected text
Steve L Walker Dec 21, 2010 4:27 PM (in response to past-tense)Yes, xfa.event.selStart and xfa.event.selEnd can be used on the change event but the properties are populated with the indexes upon change only. I don't see how they can be used to capture the start and end index based upon focus and highlighting alone.
Steve
-
6. Re: Text Field - Get selected text
pguerett Dec 22, 2010 5:29 AM (in response to Steve L Walker)If you are trying to apply richText attributes to the text then doing it programmatically will be very difficult. Once in the field you can hit the Ctrl-E key sequence the Rich Text Field toolbar will appear and allow you to apply the appropriate styles to the selected text.
Hope that helps
Paul
-
7. Re: Text Field - Get selected text
past-tense Dec 22, 2010 7:46 AM (in response to pguerett)Hello again,
I knew that it would be difficult when I started this project, but I like to think that nothing is impossible. I already have a working knowledge of how to dynamically format text, thanks to a tutorial that provided an 'envelope' for formatted text. I'm able to have a button called bold, and a textbox where the user enters the start/stop indexes. I have that test form working, I just want to be able to get the indexes from the highlighted text.
I think that I have a workable idea. I'm going to be trying this today, and I'll let you all know how it goes. I've read up on the 'Change' event properties... I think that if I can just find a way to programatically overwrite the selection on the exit event, that will trigger the on change event... then in the change event, check to se if the 'changed' property contains the value that was used on exit. If it was, restore the prevtext, then capture the selstart/selend to be used in formatting.
The only issue with this that I can see is how to programatically overwrite the selection on exit to trigger the change event.
I'll be playing with this until I get it, or until I finally admit defeat. I would appreciate any help or thoughts that anyone may have to offer. If I manage to get this working, I'll provide a custom control containing the rich text field and the formatting controls.
And yes, I know about the formatting controls that are inherant within acrobat, but my users want more that what has been provided... and they don't like that the toolbar can 'disappear' on them. Having it on the form, just above the text field would make them happy.
Thanks again to everyone who has been replying.
- Scott



