replace char at cursor

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
Preston Shea
Posts: 73
Joined: Sat Apr 08, 2006 6:51 pm

replace char at cursor

Post by Preston Shea » Mon May 25, 2009 1:27 am

How does one replace the char at the cursor in a field with the char typed instead of inserting the char typed?
In nova fert animus mutatas dicere formas corpora.

WaltBrown
Posts: 466
Joined: Mon May 11, 2009 9:12 pm

Post by WaltBrown » Mon May 25, 2009 5:20 am

From an amateur (me) - this question was a good learning experience :-)

I put this in the field (named "fText") script:

Code: Select all

on keydown theKey
   put word 2 of the selectedChunk into afterChar
   put theKey into char afterChar of field fText
end keydown
The selected chunk returns "char n to char m of field k" where n (word 2 of selectedChunk) is the character after the insertion point and m (word 4 of selectedChunk) the character before.

I imagine there might be a better way, like a global parameter or field property, but I couldn't find one.

Good luck,
Walt
Last edited by WaltBrown on Mon May 25, 2009 5:22 am, edited 1 time in total.
Walt Brown
Omnis traductor traditor

WaltBrown
Posts: 466
Joined: Mon May 11, 2009 9:12 pm

Post by WaltBrown » Mon May 25, 2009 5:21 am

By the way, when I said "From an amateur" I meant me, just to be clear.
Walt Brown
Omnis traductor traditor

Preston Shea
Posts: 73
Joined: Sat Apr 08, 2006 6:51 pm

insert char

Post by Preston Shea » Mon May 25, 2009 12:25 pm

Exactly what I needed. Thanks so much!
In nova fert animus mutatas dicere formas corpora.

Post Reply