autoHilite and focus (following Jacque's solution)

J. Landman Gay jacque at hyperactivesw.com
Wed Jul 6 12:43:52 EDT 2011


On 7/6/11 9:56 AM, Slava Paperno wrote:
> Thanks, Ken--but I do want traversalOn to be true: that's the natural
> behavior of a search field and the Find button:  type your target, then
>
> --click Find or
> --press Enter or
> --press Tab to focus on the Find button, then press Enter
>
> That's why I have, at the bottom of the Find button's mouseUp script, this
> command:
>
> focus on field "SearchTarget" of this card
>
> That command is followed, but only for a moment; the next moment the focus
> jumps to the card itself. That's the part I'm struggling with. Why wouldn't
> the field retain the focus if it is unlocked and its traversalOn is true?

I'm not sure. From your results, it looks like when the engine hits the 
final "end mouseup" it redirects the focus back to the object running 
the script.

Try putting your active statements into a separate handler and then just 
call that from the button. I.e., the button would have nothing but a 
"doSearch" command, and in the stack or card script, you'd have a 
"doSearch" handler that does the actual work. At the end of that 
handler, re-focus on the field. If that doesn't work, then try "send 
'doSearch' to this card in 0" in the button.

I don't use the focus command much, I set a selection instead. I usually 
use "select after fld 'searchTarget'" or "select text of fld 
'searchTarget'", which is just old habit but may avoid some of the 
issues you're having. Setting a selection sets the focus at the same time.

>
> I'm also trying to understand the logic of LC behavior so next time I don't
> have to ask the list: you say "when the focus is in the field and you go to
> click the button, the focus is shifting automatically to the button you
> clicked because the "traversalOn" property is "true".  That's puzzling. I
> would think that when you click a button, the focus shifts to it no matter
> what (unless the button is disabled). Otherwise every button with a false
> "traversalOn" property would be unclickable... no?

The buttons still get all the mouse messages and otherwise behave 
normally, they just don't get an automatic selection rectangle and 
tabbing through the controls will skip any object without traversalOn set.

-- 
Jacqueline Landman Gay         |     jacque at hyperactivesw.com
HyperActive Software           |     http://www.hyperactivesw.com




More information about the use-livecode mailing list