Getting Cursor Coordinates of Highlighted Text

This Q&A forum allows users to post and respond to "How Do I Do ....." questions. Please do not use to report (suspected) errors - you must use your regional help desk for this. The information contained in this forum has not been validated by LANSA and, as such, LANSA cannot guarantee the accuracy of the information.
Post Reply
AMunsell
Posts: 2
Joined: Wed Mar 15, 2017 5:30 am

Getting Cursor Coordinates of Highlighted Text

Post by AMunsell »

I'm working with a multi-line edit box in a reusable part that is a command handler for a framework.

The multi-line edit box allows users to input a large blob of text that is then pushed to a Word Document.

In order to allow users to circumvent having to use Word when they are finished, I would like to implement simple formatting tools inside my reusable part (bold, underline, italicize, page breaks, text color, etc). In order to get certain text formatting tools to work, I need to be able to track the start and end point of where text is highlighted. Currently, I can only get the end of where text is highlighted by using the CurrentLine and CharacterPosition methods.

Is there a way to determine the start position of where a user has highlighted inside of a multi-line edit box (memo box)?
VLNinja70

Re: Getting Cursor Coordinates of Highlighted Text

Post by VLNinja70 »

I got something like this working using a widget
that's stuffed inside of a web page
that's stuffed inside of the activeX Browser control
that's stuffed inside of a form.
(LANSA inception :shock: )

Using JS, you can easily accomplish this with ranges and selects.
http://stackoverflow.com/questions/1365 ... n-textarea

The only catch was I had to use my Web page to do the IO layer, which talked to a server module to bring whatever data I wanted to and from the widget. So the form just turned into a container at this point.

But yeah, I don't think there is a way you can do this with just the text area control because like you said, it can only detect where the cursor is currently at but not where I started highlighting.

Hopefully this helps a little bit,
Good luck! :P
AMunsell
Posts: 2
Joined: Wed Mar 15, 2017 5:30 am

Re: Getting Cursor Coordinates of Highlighted Text

Post by AMunsell »

VLNinja70 wrote:I got something like this working using a widget
that's stuffed inside of a web page
that's stuffed inside of the activeX Browser control
that's stuffed inside of a form.
(LANSA inception :shock: )

Using JS, you can easily accomplish this with ranges and selects.
http://stackoverflow.com/questions/1365 ... n-textarea

The only catch was I had to use my Web page to do the IO layer, which talked to a server module to bring whatever data I wanted to and from the widget. So the form just turned into a container at this point.

But yeah, I don't think there is a way you can do this with just the text area control because like you said, it can only detect where the cursor is currently at but not where I started highlighting.

Hopefully this helps a little bit,
Good luck! :P
That's exactly what I ended up doing haha. I made a WAM with a Javascript frontend that takes in a GET parameter to route the user to where they need to go. I then use Javascript in a proprietary editor to markup the users' text, then submit it via the WAM. All of this is done in the VA_WEBCTL ActiveX control in a reusable part.

As far as I know, and according to LANSA support, this is the only way to go about this as of now.
Post Reply