Using stacks as Dialogs

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
Eric
Posts: 14
Joined: Thu Oct 01, 2009 9:16 am

Using stacks as Dialogs

Post by Eric » Thu Dec 03, 2009 11:53 am

I'd like to use a stack as a sort of input dialog box.

There would be various fields and radio buttons in the "dialog" stack.

I'd like my script to pause for input, show the "dialog" window and allow the user to input data.

When the user hits an "OK" button, or the return key, I would like the calling script to resume from where it paused and make use of the input data.

How would I set this up in Revolution? Is it possible?

(To be honest, my calling script will itself have been called through AppleTalk from Excel VBA, and my Excel macro, which treats it as a function, will be waiting for a reply from the calling script, detailing the results of this RunRev "dialog box." I find I am able to shunt the called and returned parameters back and forth easily enough between the two applications. But the Excel macro will only pause whilst the called script is running - which is why I want the Rev script to pause until the user hits "OK", then resume in order to return the newly entered params to Excel.)

malte
Posts: 1098
Joined: Thu Feb 23, 2006 8:34 pm
Contact:

Re: Using stacks as Dialogs

Post by malte » Thu Dec 03, 2009 3:16 pm

Does go "yourStack" as modal solve this?

Cheers,

Malte

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

Re: Using stacks as Dialogs

Post by dunbarx » Thu Dec 03, 2009 4:38 pm

I think it is dicey to set up some sort of wait or repeat loop and then poll whether the returnKey is pressed. You are asking that the returnKey sort of interrupt the handler.

Is a single calling handler really required? Could you use two? If so, it sounds like you do not need to have the script "wait" for the input. You simply open the dialog when you need to and stop. The user can enter data, hit the return button, and another script could take over from there.

Eric
Posts: 14
Joined: Thu Oct 01, 2009 9:16 am

Re: Using stacks as Dialogs

Post by Eric » Fri Dec 04, 2009 9:52 am

Thank you so much. I think that was exactly what I was after.

I had to set up OK and Cancel buttons along the following lines:

on mouseUp
global Clicked
put "OK" into Clicked
close this stack
end mouseUp

Once closed, the calling script resumes, and can glean information from the altered card (since a "closed" stack is not actually purged from memory - merely from sight).

Big help.
Cheers, Malte.

(I take your point dunbarx but, in this instance, it was necessary to pause the calling script and wait for input - because an outside application was waiting for returned parameters - and would itself resume as soon as the calling script was cancelled. The alternative - sending messages back and forth via Appletalk - would have been less wieldy, more complicated to plan out, and pose problems when users changed their minds and cancelled)

FourthWorld
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10045
Joined: Sat Apr 08, 2006 7:05 am
Contact:

Re: Using stacks as Dialogs

Post by FourthWorld » Fri Dec 04, 2009 5:56 pm

It may be worth looking up the dialogData global property in the Dictionary as an alternative to using a global. There's nothing wrong with using globals for that, but I'm lazy and enjoy not having to declare them when I can avoid it.
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn

trevordevore
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 1005
Joined: Sat Apr 08, 2006 3:06 pm
Contact:

Re: Using stacks as Dialogs

Post by trevordevore » Fri Dec 04, 2009 7:14 pm

There is a lesson on the RunRev site that shows how to use the dialogData with modal stacks. It might be useful as well.

How Can I Pass Data To and Get Data From a Dialog Window?
Trevor DeVore
ScreenSteps - https://www.screensteps.com

LiveCode Repos - https://github.com/search?q=user%3Atrevordevore+topic:livecode
LiveCode Builder Repos - https://github.com/search?q=user%3Atrevordevore+topic:livecode-builder

Eric
Posts: 14
Joined: Thu Oct 01, 2009 9:16 am

Re: Using stacks as Dialogs

Post by Eric » Sat Dec 05, 2009 6:46 am

Thank you all. I will look up dialogData.

Post Reply