Page 1 of 1

Detecting Position of Cursor in Field

Posted: Thu Mar 15, 2012 12:45 am
by doobox
Hi there,

I am currently doing this in a button handler :

Code: Select all

on mouseUp
   put "Test Text" after field "htmlContent" 
end mouseUp
So OK this is inserting some per-configured text at the end of any current text as the user types.. reasonably acceptable in the app.

What i would really like to do, to enable the user to enter this pre-configured text any where in the text at any time is something like this :

Code: Select all

on mouseUp
   put "Test Text" after theFlashingCursor of field "htmlContent" 
end mouseUp
I cant find any way to get the offset of the cursor in the text field.. Is this possible..?

Re: Detecting Position of Cursor in Field

Posted: Thu Mar 15, 2012 12:53 am
by sturgis
Probably the easiest thing to do would be
put "my text to insert" into the selection

This way it will insert it at the cursor. If the user has selected text it will replace the selected text with whatever you "put" into the selection so that it behaves like a standard paste.

Re: Detecting Position of Cursor in Field

Posted: Thu Mar 15, 2012 1:02 am
by doobox
Hi there,

That was painless :-)

Just goes to show.. "Livecode.. Minutes to learn and a lifetime to master"