How to determine the insertion point position [Solved]

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
atout66
Posts: 266
Joined: Wed Feb 02, 2011 12:31 pm

How to determine the insertion point position [Solved]

Post by atout66 » Thu Apr 14, 2016 1:07 pm

Hi to all,

Any idea how I can decide to put the insertion point in a specific line of a field which I give the focus?
The dictionnary says about the insertion point :
The location in a field or text box where text you type will appear.
Thanks in advance, Jean-Paul.
Last edited by atout66 on Thu Apr 14, 2016 5:53 pm, edited 1 time in total.
Discovering LiveCode Community 6.5.2.

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10330
Joined: Wed May 06, 2009 2:28 pm

Re: How to determine the insertion point position

Post by dunbarx » Thu Apr 14, 2016 2:00 pm

Hi.

Several ways to do this, and they mostly depend on how you gain focus in a field. Just as a first go, I made three fields. One of them has several lines of text,and this in its script:

Code: Select all

on openField
   select before char 5 of line 3 of me
end openField
If you tab from field to field, you get that selection.

Does this do anything for you?

Craig Newman

atout66
Posts: 266
Joined: Wed Feb 02, 2011 12:31 pm

Re: How to determine the insertion point position

Post by atout66 » Thu Apr 14, 2016 2:34 pm

Hi Craig Newman, thanks for your help but for my script below, I doesn't see any change...

Code: Select all

copy line 4 of fld "laDefinition"
     focus on nothing
     focus on fld "laCible"
     select before char 3 of line 3 of fld "laCible"
     if the clipboard is "text" then paste -- it is supposed to paste into line 3 of fld "laCible" but it doesn't and no insertion point to see
They are several chars in line 3, I mean more than 3 chars :wink:
Discovering LiveCode Community 6.5.2.

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10330
Joined: Wed May 06, 2009 2:28 pm

Re: How to determine the insertion point position

Post by dunbarx » Thu Apr 14, 2016 4:14 pm

They are several chars in line 3, I mean more than 3 chars
So do you want the whole line? Originally you asked to place the insertion point only. Do you want to select a word, line, what?

Craig

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10330
Joined: Wed May 06, 2009 2:28 pm

Re: How to determine the insertion point position

Post by dunbarx » Thu Apr 14, 2016 4:23 pm

Try this in a field with several lines, and only a few chars in each line, so you can see what is happening:

Code: Select all

on mouseUp
   put random(999) into line 1 of fld 1
   copy line 1 of fld 1
   put the clipboardData into temp
   delete the last char of temp
   set the clipBoardData to temp --to lose return in line 1
     focus on nothing
     focus on fld 1
     select before char 1 of line 3 of fld 1
     if the clipboard is "text" then paste
end mouseUp
Did you also want to leave the insertion point after the paste? You should be able to do that, no?

Craig

jacque
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 7393
Joined: Sat Apr 08, 2006 8:31 pm
Contact:

Re: How to determine the insertion point position

Post by jacque » Thu Apr 14, 2016 5:43 pm

If you are only trying to move text and you're using paste to preserve unicode, use the same method in your other thread. Put the unicodetext before char 3 in the target field.

But you don't need to worry about unicode in LC 7, it's automatic. If at all possible you'll find it much easier to work with 7.

If you do continue using copy /paste you can omit both "focus" lines, selecting sets the focus for you.
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com

atout66
Posts: 266
Joined: Wed Feb 02, 2011 12:31 pm

Re: How to determine the insertion point position

Post by atout66 » Thu Apr 14, 2016 5:44 pm

Thanks Craig for your help.
I tried your script but nothing happend. I suppose it's because I use an old version of LC.

Never mind :wink:
Discovering LiveCode Community 6.5.2.

atout66
Posts: 266
Joined: Wed Feb 02, 2011 12:31 pm

Re: How to determine the insertion point position

Post by atout66 » Thu Apr 14, 2016 5:52 pm

jacque wrote:If you are only trying to move text and you're using paste to preserve unicode, use the same method in your other thread. Put the unicodetext before char 3 in the target field.
You're right, that's what I decided
But you don't need to worry about unicode in LC 7, it's automatic. If at all possible you'll find it much easier to work with 7.

Not sure of it. I tried last year (I think...) a new version of LC. It was the 7, and I realized it was really slow to show fields with a lot of text (more than 400 000 lines in one field)
I should change my mind now, but the job should be finish in few month ...
If you do continue using copy /paste you can omit both "focus" lines, selecting sets the focus for you.
It's good to know, thanks :wink:
Discovering LiveCode Community 6.5.2.

Post Reply