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 » Sat Jun 17, 2017 5:29 pm

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 » Sat Jun 17, 2017 5:45 pm

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 » Sat Jun 17, 2017 5:52 pm

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 » Sat Jun 17, 2017 6:06 pm

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: 10322
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 » Sat Jun 17, 2017 8:31 pm

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: 738
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 » Mon Jun 19, 2017 3:55 pm

For the great advice thank you.
yoda.png
yoda.png (118.48 KiB) Viewed 6568 times

Klaus
Posts: 14198
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 » Mon Jun 19, 2017 5:16 pm

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 » Mon Jun 19, 2017 5:57 pm

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

Post Reply