Detecting Position of Cursor in Field

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
doobox
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 284
Joined: Tue May 24, 2011 11:47 pm

Detecting Position of Cursor in Field

Post by doobox » Thu Mar 15, 2012 12:45 am

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..?
Kind Regards
Gary

https://www.doobox.co.uk

sturgis
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 1685
Joined: Sat Feb 28, 2009 11:49 pm

Re: Detecting Position of Cursor in Field

Post by sturgis » Thu Mar 15, 2012 12:53 am

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.

doobox
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 284
Joined: Tue May 24, 2011 11:47 pm

Re: Detecting Position of Cursor in Field

Post by doobox » Thu Mar 15, 2012 1:02 am

Hi there,

That was painless :-)

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

https://www.doobox.co.uk

Post Reply