How to insert text at cursor position?

Claus Dreischer claus at
Wed Apr 28 15:57:54 EDT 2010

Thanks Jacqueline,

that's exactly what i was looking for.
For reference, this is what i have working now:

In the field:

global g_selection

on mousedown theMouse
   put the selectedchunk into g_selection
   popup button "bt_popup"
end mousedown

in the popup button "bt_popup":

global g_selection

on menuPick pItemName
   select g_selection

   switch pItemName
      case "Non Breaking Space"
         put " " after the selection
      case "Line Break"
         put "<br>" after the selection
   end switch
end menuPick

Am 27.04.10 21:49, schrieb J. Landman Gay:
> Claus Dreischer wrote:
>> The problem was here was indeed the hilite.
>> Putting
>>     put "hello world" into the selection
>> or
>>     put "hello world" after the selection
>> in a button works.
>> Putting one of the above into a popup button doen't work.
>> So, is there a way to somehow "store" the selection before it get lost?
>> Can i insert text into a field from a popup button?
> You have a couple of choices. The easiest is to just turn off
> auto-hilite and substitute your own handlers. On mousedown, hilite the
> button, on mouseUp and mouseRelease, unhilite it.
> The second way is to use a local script variable to store the
> selectedchunk. When the button is released, reselect the stored chunk:
> local sStoredChunk
> on mouseDown
>  put the selectedchunk into sStoredChunk
> end mouseDown
> on mouseUp
>  select sStoredChunk
> end mouseUp
> on mouseRelease
>  select sStoredChunk
> end mouseRelease

More information about the Use-livecode mailing list