exitField firing multiple times

Got a LiveCode personal license? Are you a beginner, hobbyist or educator that's new to LiveCode? This forum is the place to go for help getting started. Welcome!

Moderators: heatherlaine, Klaus, FourthWorld, kevinmiller

Post Reply
KimD
Posts: 151
Joined: Wed Jul 08, 2015 5:51 am
Location: Wellington, New Zealand

exitField firing multiple times

Post by KimD » Thu Jun 07, 2018 11:57 pm

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

KimD
Posts: 151
Joined: Wed Jul 08, 2015 5:51 am
Location: Wellington, New Zealand

Re: exitField firing multiple times

Post by KimD » Fri Jun 08, 2018 3:07 am

Sample stack attached
Attachments
CloseField.7z
(664 Bytes) Downloaded 6 times

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 5390
Joined: Wed May 06, 2009 2:28 pm
Location: New York, NY

Re: exitField firing multiple times

Post by dunbarx » Fri Jun 08, 2018 3:25 am

Hi.

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

Is the handler in the card script?

Craig Newman

KimD
Posts: 151
Joined: Wed Jul 08, 2015 5:51 am
Location: Wellington, New Zealand

Re: exitField firing multiple times

Post by KimD » Fri Jun 08, 2018 3:30 am

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

SparkOut
Posts: 1741
Joined: Sun Sep 23, 2007 4:58 pm

Re: exitField firing multiple times

Post by SparkOut » Fri Jun 08, 2018 6:51 am

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.

jacque
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 4453
Joined: Sat Apr 08, 2006 8:31 pm
Location: Minneapolis MN
Contact:

Re: exitField firing multiple times

Post by jacque » Fri Jun 08, 2018 4:48 pm

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
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com

FourthWorld
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 5962
Joined: Sat Apr 08, 2006 7:05 am
Location: Los Angeles
Contact:

Re: exitField firing multiple times

Post by FourthWorld » Fri Jun 08, 2018 4:55 pm

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?
Richard Gaskin
Community volunteer LiveCode Community Liaison

LiveCode development, training, and consulting services: Fourth World Systems: http://FourthWorld.com
LiveCode User Group on Facebook : http://FaceBook.com/groups/LiveCodeUsers/

KimD
Posts: 151
Joined: Wed Jul 08, 2015 5:51 am
Location: Wellington, New Zealand

Re: exitField firing multiple times

Post by KimD » Fri Jun 08, 2018 11:28 pm

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

jacque
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 4453
Joined: Sat Apr 08, 2006 8:31 pm
Location: Minneapolis MN
Contact:

Re: exitField firing multiple times

Post by jacque » Sat Jun 09, 2018 5:30 pm

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.
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com

Post Reply

Return to “Getting Started with LiveCode - Complete Beginners”