How to enter chars at the place one clicked on? [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
gtheus
Posts: 13
Joined: Sun Jan 27, 2008 11:44 am

How to enter chars at the place one clicked on? [SOLVED]

Post by gtheus » Sat Jan 29, 2022 5:06 pm

I want to enter "(·)" into a word in a label at the position where a user clicked: "example" should become "examp(·)le" afterwards (it's for an educational training on hyphenation).
I found the function clickChar. It returns the character the user has clicked on, which is fine. But how can I insert "(·)" after this character? I need to get the position of the clicked char in the field, somehow - but how? Other solutions?
Last edited by gtheus on Sat Jan 29, 2022 9:46 pm, edited 2 times in total.

jmburnod
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 2729
Joined: Sat Dec 22, 2007 5:35 pm
Contact:

Re: How to enter chars at the place one clicked on?

Post by jmburnod » Sat Jan 29, 2022 5:37 pm

Hi,
It seems clickcharchunk function does the job

Code: Select all

on mouseup
   put "(.)" into the clickcharchunk
end mouseup
Best regards
Jean-Marc
https://alternatic.ch

gtheus
Posts: 13
Joined: Sun Jan 27, 2008 11:44 am

Re: How to enter chars at the place one clicked on?

Post by gtheus » Sat Jan 29, 2022 5:46 pm

That's it! Much easier than I feared... :D
I modified your solution to…

Code: Select all

put "(.)" after the clickcharchunk
…to get the desired solution.
Thank you for this quick help!

richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 10078
Joined: Fri Feb 19, 2010 10:17 am

Re: How to enter chars at the place one clicked on?

Post by richmond62 » Sat Jan 29, 2022 5:49 pm

Insert.png
Attachments
INSERT.livecode.zip
Here's the stack.
(1.36 KiB) Downloaded 170 times

gtheus
Posts: 13
Joined: Sun Jan 27, 2008 11:44 am

Re: How to enter chars at the place one clicked on?

Post by gtheus » Sat Jan 29, 2022 9:48 pm

Thank you both for your help!

jmburnod
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 2729
Joined: Sat Dec 22, 2007 5:35 pm
Contact:

Re: How to enter chars at the place one clicked on? [SOLVED]

Post by jmburnod » Sat Jan 29, 2022 11:03 pm

Hi Richmond,
I tested your script but it doesn't work
I get an error, "chunk: no target found" because the selectedchunk is empty
Kind regards
Jean-Marc
https://alternatic.ch

richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 10078
Joined: Fri Feb 19, 2010 10:17 am

Re: How to enter chars at the place one clicked on? [SOLVED]

Post by richmond62 » Sun Jan 30, 2022 9:28 am

SShot 2022-01-30 at 10.25.22.png
-
Working perfectly in the Balkans. 8)

LC 9.6.3 / MacOS 12.3 RC1

jmburnod
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 2729
Joined: Sat Dec 22, 2007 5:35 pm
Contact:

Re: How to enter chars at the place one clicked on? [SOLVED]

Post by jmburnod » Sun Jan 30, 2022 10:56 am

Sorry Richmond,
it works with traversalon = true :D
(not needed with clickcharchunk)
Best
Jean-Marc
https://alternatic.ch

richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 10078
Joined: Fri Feb 19, 2010 10:17 am

Re: How to enter chars at the place one clicked on? [SOLVED]

Post by richmond62 » Sun Jan 30, 2022 11:56 am

Sorry Richmond,
it works with traversalon = true :D
(not needed with clickcharchunk)
Quite possibly, but over here my stack works exactly as I programmed it.

Post Reply