How to insert text at cursor position?

J. Landman Gay jacque at
Tue Apr 27 15:49:02 EDT 2010

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

Jacqueline Landman Gay         |     jacque at
HyperActive Software           |

More information about the Use-livecode mailing list