Modal dialogue "it"
Ken Ray
kray at sonsothunder.com
Fri Oct 8 23:05:44 EDT 2004
On 10/8/04 9:08 PM, "Andrew" <alw918 at earthlink.net> wrote:
> Hi, I have a strange problem.
> I'm doing a very simple procedure where my main stack calls a substack
> as modal. Then, when you push "OK" in the substack, the substack
> closes and the contents of its field "response" is put into it.
> Then, after the modal stack is closed, more code is supposed to run,
> but it just stops there, and it seems as though "it" was erased.
> My mainstack says this:
> on keydown whichkey
> put whichkey into field "response" of stack "dialog"
> modal "dialog"
> answer it
> if not it contains "cancel" then send continueStuff to this card
> end keydown
>
> I put "answer it" there just as a test (so that Rev would show me what
> was put into "it" after the modal dialog stack closes), and it just
> answers with a blank window.
I wouldn't use "it" for this... there's a special global property called
"the dialogData" that I use and it is flawless. Your modal stack's OK button
should be:
on mouseUp
global recentvar
set the dialogData to cd fld "response"
put cd fld "response" into recentvar
close stack "dialog"
end mouseUp
and your mainstack should say:
modal "dialog"
answer the dialogData
if the dialogData contains "cancel" then ...
BTW: A couple of suggestions:
1) Make sure you put quotes around all your object names (i.e. 'cd fld
"response"', not 'cd fld response')
2) I probably wouldn't name a stack with a common name like "dialog" - it
may become a reserved word some day.
3) Rather than 'close stack "dialog"' you can just say 'close this stack',
since it is apparently being executed in the stack "dialog".
4) You might want to use "hungarian notation" with your global variables,
prefacing them with "g", like "gRecentVar". Many of us do this - the skinny
is here:
http://www.fourthworld.com/embassy/articles/scriptstyle.html
HTH,
Ken Ray
Sons of Thunder Software
Web site: http://www.sonsothunder.com/
Email: kray at sonsothunder.com
More information about the use-livecode
mailing list