selectedText from a palette?

depstein at depstein at
Thu Sep 9 11:13:10 EDT 2004

Rich Layne wrote:

> I trying to make an application that has most of it’s functionality on 
> a palette-- a bunch of different buttons that will do different stuff 
> to the main data stack. Most things work, but handlers that involve the 
> “selectedText” don’t seem to make it to the main stack, (which is the 
> topStack.) 

My experience using Metacard 2.5 is that when you click on a palette the selection in the topStack is lost, so the selectedText is empty.  I use these handlers in my palette's script as a way of recording and restoring the selection:

on mouseEnter
  global chunkStore
  get the selectedChunk
  if it is empty then put empty into chunkStore else put it && "of" && word -2 to -1 of the long id of the selectedField into chunkStore
end mouseEnter

on mouseDown
  global chunkStore
  if chunkStore is not empty then do "select" && chunkStore
end mouseDown

So on mouseUp, the selection is where you want it and references to it should work properly.  

There is a slight flashing associated with the selection being lost and restored, so I'd be interested to hear other methods.

David Epstein

More information about the use-livecode mailing list