Page 1 of 1

location of clickline

Posted: Fri Apr 13, 2018 4:58 pm
by Da_Elf
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.

Re: location of clickline

Posted: Fri Apr 13, 2018 5:18 pm
by jmburnod
Hi,
You may use "selectedloc" to get the location of the top left corner of the text selection.
Best regards
Jean-Marc

Re: location of clickline

Posted: Fri Apr 13, 2018 5:48 pm
by Da_Elf
only worked with fields that can be hilited. shame. but it gave me some ideas

Re: location of clickline

Posted: Fri Apr 13, 2018 6:19 pm
by Fermin
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

Re: location of clickline

Posted: Fri Apr 13, 2018 6:36 pm
by jmburnod
only worked with fields that can be hilited. shame. but it gave me some ideas
Why not:

Code: Select all

   lock screen
   put the clickline
   select the clickline 
   put the selectedloc into tSelLoc
   select empty
   put tSelLoc

Re: location of clickline

Posted: Fri Apr 13, 2018 6:39 pm
by dunbarx
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:

Code: Select all

on mouseMove x,y
put y
end mouseMove
If you are not averse to using the rawkeyDown message in a kluge, you could in the field or card script:

Code: Select all

 on rawKeyDown
    put the mouseV  && the target
 end rawKeyDown
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

Re: location of clickline

Posted: Fri Apr 13, 2018 6:44 pm
by jmburnod
Thanks Fermin,
I think the formattedTop of line x of fld xxx is a better way than my quick and dirty solution.

Re: location of clickline

Posted: Fri Apr 13, 2018 6:51 pm
by dunbarx
Another kluge. So you have an unlocked field, eh?

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
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