Weird defaultStack behavior

Peter Haworth pete at
Tue Feb 1 00:05:00 EST 2011

I have something strange going on  related to the setting of the defaultStack.  It's a little complicated t0 explain, I'll do my best.

My application puts up a modal dialog window ( "ModalCardB") when the user clicks on a button on a particular card  "CardA".  

ModalCardB starts off life with two controls on it but the user can add more pairs of these controls by clicking on a third button control.  

Each new pair of controls is created by copying the first pair, setting their rectangle to position them beneath the original pair, and changing the height of the stack.  

When the user clicks on a final button to close ModalCardB, I set the dialogData to the contents of all the pairs of controls, one per line, delete all the pairs of controls except the original pair, and close ModalCardB.  

After ModalCardB is closed, the script of the CardA button grabs the dialogData and continue to process it.

Here's the problem.  

Immediately after I come out of ModalCardB, the defaultstack is set differently depending on whether the user filled in just the initial pair of controls or added more pairs.  

When just the initial pair of controls is used, the defaultStack is set to CardA's stack.  

When more than one pair of controls is used, the defaultStack is set to ModalCardB's stack, which totally messes up CardA's button script.  I can't hard code the stack name because this is a generic script I want to use in many places.

What could be causing this?  I assume it must be something to do with dynamically adding and deleting controls to the modal card, but maybe it's a bug?  If it is a bug, how can I work around it?

Pete Haworth

More information about the use-livecode mailing list