Set Main Stack Card from Modal

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: FourthWorld, heatherlaine, Klaus, kevinmiller

Post Reply
velcrobelly
Posts: 7
Joined: Sat Apr 25, 2020 8:27 pm

Set Main Stack Card from Modal

Post by velcrobelly » Thu May 07, 2020 8:28 pm

Is it possible to click on a button in a modal dialog that will then close the modal and change the card in the main stack?

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10320
Joined: Wed May 06, 2009 2:28 pm

Re: Set Main Stack Card from Modal

Post by dunbarx » Thu May 07, 2020 8:34 pm

I don't see why not. Have you tried it?

Certainly navigate to the card of interest before you close the stack. This means you must explicitly close the original stack, since you are no longer there.
You might want to lock the screen.

Craig

velcrobelly
Posts: 7
Joined: Sat Apr 25, 2020 8:27 pm

Re: Set Main Stack Card from Modal

Post by velcrobelly » Thu May 07, 2020 8:39 pm

I have tried:

Code: Select all

on mouseUp
   go to card "card_acounts"
   close this stack
end mouseUp
and it closes the modal, but does not go to the card.

Klaus
Posts: 14194
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: Set Main Stack Card from Modal

Post by Klaus » Thu May 07, 2020 9:01 pm

Hi velcrobelly,

there are several ways to do so. :D
I would probably do something like:

Code: Select all

on mouseup
  send "go to cd card_accounts" to stack "the one with that namely card" in 1
  close this stack
end mouseup
Best

Klaus

velcrobelly
Posts: 7
Joined: Sat Apr 25, 2020 8:27 pm

Re: Set Main Stack Card from Modal

Post by velcrobelly » Thu May 07, 2020 9:55 pm

Klaus, thank you for the response.

On the button in the modal I have placed:

Code: Select all

on mouseup
  send "go to cd card_accounts" to stack "MainStack" in 1
  close this stack
end mouseup
However, it only closes the modal and does not switch the card. BTW, I am using a substack as the modal.

I also noticed that if I comment out "close this stack" it does make the switch. So, is it closing before it can do the rest?

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10320
Joined: Wed May 06, 2009 2:28 pm

Re: Set Main Stack Card from Modal

Post by dunbarx » Thu May 07, 2020 10:53 pm

Hi.

If you go to the card of interest, you are on the stack of interest. If you then close "this stack", you will close, er, this stack, that is, the one that contains the card you are already on. This ignores the original stack.

I mentioned earlier that you should 1) go to the card of interest then 2) explicitly close the stack you navigated FROM.

If I understand at all what you are trying to do.

Craig

velcrobelly
Posts: 7
Joined: Sat Apr 25, 2020 8:27 pm

Re: Set Main Stack Card from Modal

Post by velcrobelly » Thu May 07, 2020 11:41 pm

Thanks, Dunbarx. The following appears to work:

Code: Select all

on mouseup
  send "go to cd card_accounts" to stack "MainStack" in 1
  send "close stack modal_dialog" to stack "MainStack" in 1
end mouseup

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10320
Joined: Wed May 06, 2009 2:28 pm

Re: Set Main Stack Card from Modal

Post by dunbarx » Fri May 08, 2020 1:01 am

Bingo!!!

And I bet you can see a little more clearly where you started from, where you ended up, and what you did along the way. All good stuff.

Craig

Post Reply