Page 1 of 1

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

Posted: Sat Jan 29, 2022 5:06 pm
by gtheus
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?

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

Posted: Sat Jan 29, 2022 5:37 pm
by jmburnod
Hi,
It seems clickcharchunk function does the job

Code: Select all

on mouseup
   put "(.)" into the clickcharchunk
end mouseup
Best regards
Jean-Marc

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

Posted: Sat Jan 29, 2022 5:46 pm
by gtheus
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!

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

Posted: Sat Jan 29, 2022 5:49 pm
by richmond62
Insert.png

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

Posted: Sat Jan 29, 2022 9:48 pm
by gtheus
Thank you both for your help!

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

Posted: Sat Jan 29, 2022 11:03 pm
by jmburnod
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

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

Posted: Sun Jan 30, 2022 9:28 am
by richmond62
SShot 2022-01-30 at 10.25.22.png
-
Working perfectly in the Balkans. 8)

LC 9.6.3 / MacOS 12.3 RC1

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

Posted: Sun Jan 30, 2022 10:56 am
by jmburnod
Sorry Richmond,
it works with traversalon = true :D
(not needed with clickcharchunk)
Best
Jean-Marc

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

Posted: Sun Jan 30, 2022 11:56 am
by richmond62
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.