Detect where clicked in text Box (1 Viewer)

kirkm

Registered User.
Local time
Tomorrow, 03:04
Joined
Oct 30, 2008
Messages
1,257
Can I use any text box event to find what row or where I've clicked?
My aim is to extract some words from the line of text I click on.
Thanks for any help
 

kirkm

Registered User.
Local time
Tomorrow, 03:04
Joined
Oct 30, 2008
Messages
1,257
No, the text box has an unknown number of lines, some wrapped (possibly) and a vertical scrollbar. I was hoping to find which line I'd clicked onto, and from there capture some text from that line. (It is a known format for each line).
I didn't think it would be easy!
What it some of the text was selected ? Would that be possible ?
 

Gasman

Enthusiastic Amateur
Local time
Today, 16:04
Joined
Sep 21, 2011
Messages
14,218
If you used .selstart as the starting point, could you not look for a CR/LF and then select everything in between.?

Lot of work for just a drag of a mouse I would have thought though.?
What if you wanted two lines.?
How you you copy the text, button?, that is an extra click as well.?

No, the text box has an unknown number of lines, some wrapped (possibly) and a vertical scrollbar. I was hoping to find which line I'd clicked onto, and from there capture some text from that line. (It is a known format for each line).
I didn't think it would be easy!
What it some of the text was selected ? Would that be possible ?
 

Galaxiom

Super Moderator
Staff member
Local time
Tomorrow, 01:04
Joined
Jan 20, 2009
Messages
12,851
No, the text box has an unknown number of lines, some wrapped (possibly) and a vertical scrollbar. I was hoping to find which line I'd clicked onto, and from there capture some text from that line. (It is a known format for each line).

Sounds like the lines should be being treated as different pieces of data.

Having said that, the Mouse Down Event returns the X and Y coordinates of the click. You can compare this with the font size and the Top and Left of the textbox to determine what line you are on.

I don't think Access has anything to handle the possibility of it being scrolled though. Might be something in Windows API that could return how far down it is since Windows needs to display the scroll bar in the right position.

Many years ago I posted something on here about calculating the heights of text from the font size. I don't recall the details.
 

kirkm

Registered User.
Local time
Tomorrow, 03:04
Joined
Oct 30, 2008
Messages
1,257
Thanks for the replies. I learned something quite useful... looking at .SelStart I found .SelText which does exactly what's required - returning the selected text via MouseUp.
.
 

The_Doc_Man

Immoderate Moderator
Staff member
Local time
Today, 10:04
Joined
Feb 28, 2001
Messages
27,124
Ah, then I wasn't that far off after all. Glad I pointed you there.
 

Users who are viewing this thread

Top Bottom