location of clickline
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller
location of clickline
I wish i could figure this out. trying to get the screen location of a clicked line on a field. Using a simple mouseLoc isnt reliable. i want the exact position of the line.
-
- VIP Livecode Opensource Backer
- Posts: 2718
- Joined: Sat Dec 22, 2007 5:35 pm
- Location: Genève
- Contact:
Re: location of clickline
Hi,
You may use "selectedloc" to get the location of the top left corner of the text selection.
Best regards
Jean-Marc
You may use "selectedloc" to get the location of the top left corner of the text selection.
Best regards
Jean-Marc
https://alternatic.ch
Re: location of clickline
only worked with fields that can be hilited. shame. but it gave me some ideas
Re: location of clickline
Maybe this can help? At least for the height...
put the formattedTop of line x of fld xxx into n1 -- relative to the stack window
put the top of this stack into n2
put n1 + n2 into n3 -- relative to the screen display
and the 'formattedLeft' property may also help for the horizontal localization
put the formattedTop of line x of fld xxx into n1 -- relative to the stack window
put the top of this stack into n2
put n1 + n2 into n3 -- relative to the screen display
and the 'formattedLeft' property may also help for the horizontal localization
-
- VIP Livecode Opensource Backer
- Posts: 2718
- Joined: Sat Dec 22, 2007 5:35 pm
- Location: Genève
- Contact:
Re: location of clickline
Why not:only worked with fields that can be hilited. shame. but it gave me some ideas
Code: Select all
lock screen
put the clickline
select the clickline
put the selectedloc into tSelLoc
select empty
put tSelLoc
https://alternatic.ch
-
- VIP Livecode Opensource Backer
- Posts: 9660
- Joined: Wed May 06, 2009 2:28 pm
- Location: New York, NY
Re: location of clickline
I assume you are having trouble with editable fields. Not many messages sent from those.
The "mouseMove" message is sent, though, and you can retrieve the vertical position:
If you are not averse to using the rawkeyDown message in a kluge, you could in the field or card script:
With this last you can place the cursor, press any key and then do the math. Know that the field has to have focus, unless you always know what the target field is, in which case all you need is the mouseV.
Craig Newman
The "mouseMove" message is sent, though, and you can retrieve the vertical position:
Code: Select all
on mouseMove x,y
put y
end mouseMove
Code: Select all
on rawKeyDown
put the mouseV && the target
end rawKeyDown
Craig Newman
-
- VIP Livecode Opensource Backer
- Posts: 2718
- Joined: Sat Dec 22, 2007 5:35 pm
- Location: Genève
- Contact:
Re: location of clickline
Thanks Fermin,
I think the formattedTop of line x of fld xxx is a better way than my quick and dirty solution.
I think the formattedTop of line x of fld xxx is a better way than my quick and dirty solution.
https://alternatic.ch
-
- VIP Livecode Opensource Backer
- Posts: 9660
- Joined: Wed May 06, 2009 2:28 pm
- Location: New York, NY
Re: location of clickline
Another kluge. So you have an unlocked field, eh?
In the field script:
You can change these properties in other ways, depending on how klugey you want to get. Anyway, in an unlocked field, when the user brings the cursor inside and clicks, you get what you wanted. Whether that limits other functionality or user experience needs to be addressed, I bet you can kluge your way out of it all.
Craig
In the field script:
Code: Select all
on mouseEnter
set the locktext of me to "true"
end mouseEnter
on mouseDown
put the clickLine
put word 2 of the clickChunk + 1 into tChar
set the locktext of me to "false"
select after char tChar of me
end mouseDown
Craig