How to get the line of a field the user clicked on it

LiveCode is the premier environment for creating multi-platform solutions for all major operating systems - Windows, Mac OS X, Linux, the Web, Server environments and Mobile platforms. Brand new to LiveCode? Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
RevigBreizh
Posts: 6
Joined: Sat Jun 17, 2017 5:21 pm

How to get the line of a field the user clicked on it

Post by RevigBreizh »

Hi,

I have a field with many lines.
I would like to get the number of the line of this field, the user clicked on it. The field is read-only.

If the user clicks on the second line, I would like to get "2"…

Any help?

Thanks,

Rémi
bogs
Posts: 5480
Joined: Sat Feb 25, 2017 10:45 pm

Re: How to get the line of a field the user clicked on it

Post by bogs »

I am guessing this is what you'd be looking for -
clickLine
Summary:
Returns the number of the line that the user last clicked in a field.

Examples:
select the clickLine
put the value of the clickLine into textOfClickedLine

Use the clickLine function within a mouseDown, mouseUp, or selectionChanged handler to determine which line the user clicked, in order to provide hypertext (clickable text) or take some action based on the click.

Value:
The clickLine function returns a chunk expression of the form line lineNumber of field fieldNumber.
Image
RevigBreizh
Posts: 6
Joined: Sat Jun 17, 2017 5:21 pm

Re: How to get the line of a field the user clicked on it

Post by RevigBreizh »

Exactly what I wanted!
Thank you… I didn't find it into the Dictionary at first.
bogs
Posts: 5480
Joined: Sat Feb 25, 2017 10:45 pm

Re: How to get the line of a field the user clicked on it

Post by bogs »

Yah, the dictionary can be a bit unwieldy to muck through. Generally what I find helps the most is to put, in this case, what your looking to get at.

So if you put 'line' in the search under all, it returns everything you can do with a line. You'll also find doing it that way that sometimes better options present themselves as well, as Lc has many ways to do similar things.

Glad I could help though :)
Image
dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10501
Joined: Wed May 06, 2009 2:28 pm

Re: How to get the line of a field the user clicked on it

Post by dunbarx »

What bogs said.

In that vein, you might have, just for grins, taken at look at every native word that contains the string "char".

You would have found such things as the "clickChar" and the "mouseCharChunk". And others. It is often useful, and sometime revelatory, to see that one can go deeper than previously imagined. In other words, once you are a true LC fanatic, you will automatically think to yourself ; "If I can click on a word and get stuff back, why not a letter?".

And find that you can.

The dictionary does a good job of presenting related words. Most of us pride ourselves on our ability to use google, in that we are adept at presenting it with well thought out keywords to refine searches. Same with the dictionary.

Craig Newman
mrcoollion
Posts: 744
Joined: Thu Sep 11, 2014 1:49 pm

Re: How to get the line of a field the user clicked on it

Post by mrcoollion »

For the great advice thank you.
yoda.png
yoda.png (118.48 KiB) Viewed 7517 times
Klaus
Posts: 14324
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: How to get the line of a field the user clicked on it

Post by Klaus »

I like yogurt better! :D
Image
bogs
Posts: 5480
Joined: Sat Feb 25, 2017 10:45 pm

Re: How to get the line of a field the user clicked on it

Post by bogs »

Ahh, Klaus is demonstrating the power of the Schwartz !
Image
Post Reply