Page 1 of 1

exitField firing multiple times

Posted: Thu Jun 07, 2018 11:57 pm
by KimD
I create a new stack containing one field "AAA"
- LockText is false
- FocusWithKeyboard is true
- Script is shown below:

on closeField
Answer "CloseField" & the name of me
end closeField

on exitField
Answer "ExitField" & the name of me
end exitField

1) If I click on field AAA, change its contents, and then click outside it I trigger the answer CloseField dialogue

2) If I click on field AAA, don't change its contents, and then click outside it I trigger the answer ExitField dialogue

All good so far.

3) If I then click again on the card outside of field AAA, the answer ExitField dialogue appears again. ExitField keeps firing everytime that I click outside of field AAA

4) If I click on field AAA, don't change its contents, and then click on another field with LockText = True and FocusWithKeyboard = true; I trigger TWO answer ExitField dialogues from field "AAA"

5) If I click on field AAA, change its contents, and then click on another field with LockText = True and FocusWithKeyboard = true; I trigger BOTH a CloseField and an ExitField from field "AAA"

Is there an easy way to damped the enthusiasm of exitField and get it (or CloseField) to fire only once for each openField? I've tried "Focus on nothing", but that didn't do it. Even after "Focus on nothing", exitFields keep firing for field AAA (without AAA being re-opened). I realise that I could have openField set the LetExitFieldFire of this card to true, then have closeField and exitField set the LetExitFieldFire of this card to false, and add an "if LetExitFieldFire" statement within each exitField handler; but I just wondering if there is a simple button that I can tick to solve this.

Thanks in advance

Kim

Re: exitField firing multiple times

Posted: Fri Jun 08, 2018 3:07 am
by KimD
Sample stack attached

Re: exitField firing multiple times

Posted: Fri Jun 08, 2018 3:25 am
by dunbarx
Hi.

I haven't tried your experiment, and want to ask one question first.

Is the handler in the card script?

Craig Newman

Re: exitField firing multiple times

Posted: Fri Jun 08, 2018 3:30 am
by KimD
Hi Craig

Card and stack script are empty

I am now wondering if its something to do with how exitField interacts with the Answer command.

Regards

Kim

Re: exitField firing multiple times

Posted: Fri Jun 08, 2018 6:51 am
by SparkOut
In the development menu, you can find the message watcher, which gives you a list of all the messages as they fire. In real time, so it's not easy to read, but with some judicious stopping and starting and filtering, you could track down the sequence of events and what happens immediately before the exitField.

Re: exitField firing multiple times

Posted: Fri Jun 08, 2018 4:48 pm
by jacque
What SparkOut said. Or instead of an answer dialog, just use "put" which will put the response into the message box. Either way you can rule out the dialog.

Code: Select all

 put "ExitField" & the name of me

Re: exitField firing multiple times

Posted: Fri Jun 08, 2018 4:55 pm
by FourthWorld
KimD wrote:
Fri Jun 08, 2018 3:30 am
I am now wondering if its something to do with how exitField interacts with the Answer command.
That may be. Have you tried outputting to a log field instead?

Re: exitField firing multiple times

Posted: Fri Jun 08, 2018 11:28 pm
by KimD
Thanks Craig, Sparkout, Jacque & Richard

It does appear to be something to do with an interaction between the Answer dialogue and exitField/CloseField.

When I removed "Answer" and replaced this with writing to a logfile, the results for exitField and closeField where as-documented in the LC dictionary.

Regards

Kim

Re: exitField firing multiple times

Posted: Sat Jun 09, 2018 5:30 pm
by jacque
LC automatically selects the first editable field when a card opens and that triggers all the standard field messages. I'm guessing the answer dialog has one of those somewhere which would cause what you see. I have mixed feelings about this behavior because it often gets in the way.

Typically when a handler is placed in a script where it will be triggered by controls you don't want to deal with, a check for the target fixes the problem. If the target doesn't meet your criteria, exit or pass the message.