Page 1 of 1

How to determine the insertion point position [Solved]

Posted: Thu Apr 14, 2016 1:07 pm
by atout66
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.

Re: How to determine the insertion point position

Posted: Thu Apr 14, 2016 2:00 pm
by dunbarx
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

Re: How to determine the insertion point position

Posted: Thu Apr 14, 2016 2:34 pm
by atout66
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:

Re: How to determine the insertion point position

Posted: Thu Apr 14, 2016 4:14 pm
by dunbarx
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

Re: How to determine the insertion point position

Posted: Thu Apr 14, 2016 4:23 pm
by dunbarx
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

Re: How to determine the insertion point position

Posted: Thu Apr 14, 2016 5:43 pm
by jacque
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.

Re: How to determine the insertion point position

Posted: Thu Apr 14, 2016 5:44 pm
by atout66
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:

Re: How to determine the insertion point position

Posted: Thu Apr 14, 2016 5:52 pm
by atout66
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: