Selection strategies

depstein at att.net depstein at att.net
Fri Feb 27 08:14:48 EST 2004


Richard Gaskin noted that 

> when text is selected in the field [of the topstack] the 
> palette buttons work great, but if the cursor is inserted with no 
> selection then clicking in the palette window causes the field to lose 
> focus.

My palette is a menu of pulldown buttons, and these handlers are in the palette's stack script:

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

This works properly, although there is a slight flash as the text gets reselected on mousedown, so an approach that avoided that would be welcome.  One approach:  if I test the selectedText's length and load chunkStore only if that length is <1, the engine keeps the selection without my help for cases where there's more than an insertion point, and the flash is avoided.  But in that case my experience is that the insertion point is not properly placed after the command is executed (e.g., a "paste" command does not place the insertion point after the newly pasted material), whereas the scripts above set the insertion point properly.  But there is that flash.

I'm using MC 2.5.

David Epstein


More information about the use-livecode mailing list