Passing selectedField Location between Stacks
Bernard Devlin
revolution at knowledgeworks.plus.com
Sun Dec 8 16:28:00 EST 2002
Thanks for the pointers Ken and Jeanne.
Here's what I've found.
If there is actually some selected text in the field with the insertion point,
then the label of the button can be inserted after the text (using "after the
selectedChunk"). However, if I intercept the processing of the handler in the
button palette, unless there _is_ selected text, the following all return empty:
the selectedChunk
the selectedField
the selectedLine
the selection.
If there is selected text, then they all display some value.
Because they are empty, the button's label cannot be inserted after anything
(there is no target), and I get the "chunk: no target found" error.
My understanding is that the selectedChunk should return something even if
nothing is selected. Am I wrong? According to the Transcript Dictionary:
>>
If no text is selected but the text insertion point is in a field, the
startChar is the character after the insertion point, and the endChar is the
character before the insertion point. In this case, the endChar is one less than
the startChar.
<<
Am i misunderstanding something about the way in which the target works? Or is
this a bug?
I have made the button stack into a palette, and set the traversalOn to false
for all the buttons.
> Actually anything that removes the focus from the field will prevent
> selectedField or selectedChunk from working. For example if you have on a
> single card a field and a button and put text in the field and ask (in the
> button script) for the selectedField, you'll get nothing. The reason for
> *this* occurrence is because the normal button has its 'traversalOn'
> property set to true, which gives the button the focus before it executes
> its script. If you turn the 'traversalOn' of the button off, the button can
> retrieve the selectedField just fine.
>
> In the case of another stack, if the other stack is a toplevel stack (not a
> palette), the focus will shift to the stack. If you have a palette, and the
> buttons have their 'traversalOn' set to false, you should be OK.
More information about the use-livecode
mailing list