location of clickline

Got a LiveCode personal license? Are you a beginner, hobbyist or educator that's new to LiveCode? This forum is the place to go for help getting started. Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller

Post Reply
Da_Elf
Posts: 311
Joined: Sun Apr 27, 2014 2:45 am

location of clickline

Post by Da_Elf » Fri Apr 13, 2018 4:58 pm

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.

jmburnod
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 2718
Joined: Sat Dec 22, 2007 5:35 pm
Location: Genève
Contact:

Re: location of clickline

Post by jmburnod » Fri Apr 13, 2018 5:18 pm

Hi,
You may use "selectedloc" to get the location of the top left corner of the text selection.
Best regards
Jean-Marc
https://alternatic.ch

Da_Elf
Posts: 311
Joined: Sun Apr 27, 2014 2:45 am

Re: location of clickline

Post by Da_Elf » Fri Apr 13, 2018 5:48 pm

only worked with fields that can be hilited. shame. but it gave me some ideas

Fermin
Posts: 142
Joined: Fri Jun 05, 2015 10:44 pm

Re: location of clickline

Post by Fermin » Fri Apr 13, 2018 6:19 pm

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

jmburnod
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 2718
Joined: Sat Dec 22, 2007 5:35 pm
Location: Genève
Contact:

Re: location of clickline

Post by jmburnod » Fri Apr 13, 2018 6:36 pm

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
https://alternatic.ch

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 9660
Joined: Wed May 06, 2009 2:28 pm
Location: New York, NY

Re: location of clickline

Post by dunbarx » Fri Apr 13, 2018 6:39 pm

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

jmburnod
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 2718
Joined: Sat Dec 22, 2007 5:35 pm
Location: Genève
Contact:

Re: location of clickline

Post by jmburnod » Fri Apr 13, 2018 6:44 pm

Thanks Fermin,
I think the formattedTop of line x of fld xxx is a better way than my quick and dirty solution.
https://alternatic.ch

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 9660
Joined: Wed May 06, 2009 2:28 pm
Location: New York, NY

Re: location of clickline

Post by dunbarx » Fri Apr 13, 2018 6:51 pm

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

Post Reply

Return to “Getting Started with LiveCode - Complete Beginners”