On Tuesday, Aug 24 1999, Guy LOUIS wrote:
> Yes, in this case, I want to call a function which displays a modal dialog
> box, with a list, where I can choose one of more items.
This is something thats best handled by using normal objects in MetaCard.
MetaCard supports multiple stacks inside a single stack, so you can create
dialogs and other windows very easily. Try this:
Create a new stack
Name the stack "example"
Save the stack
Create another new stack
Name the stack "example dialog"
Switch to the second tab in the Stack Properties dialog and select
"Mainstack"
Select the original "example" stack
Save this stack - note that these two stacks are now in a single file,
mainStack and subStack
Create a button in stack "example"
In the script, place:
on mouseUp
modal "example dialog"
end mouseUp
modal is an alternative to "open" or "go" - it opens a stack, but as a
"modal" - i.e. a dialog
Create a button in the "example dialog" stack
In the script, place:
on mouseUp
close this stack
end mouseUp
Switch to browse tool, and try it out - you now have a dialog
To create a scrolling list in the dialog, in the message box:
toplevel "example dialog" --opens the stack as a normal, non-modal stack
Choose the field tool and draw out a field
Edit the field's properties, put in some text, and turn on listBehavior
In the field script, put the following:
on mouseUp
put the hilitedLines of me into tLineNo
set the cExampleReturnValue of this stack to (line tLineNo of me)
end mouseUp
That sets a custom property on the stack. Custom properties are like
fields, except they're not visible and get attached to existing objects.
Use them to store information that should be persistant. They're better
than global variables (though you could have use one if you liked) because
they're object orientated and persistant (i.e. they save).
To access the value the user returned, in the original stack, you could have
a script that did something like:
on mouseUp
modal "example dialog"
if the cExampleReturnValue of stack "example dialog" is "my item 1" then
--etc.
end if
end mouseUp
You could add a cancel button to the dialog by adding another button:
on mouseUp
set the cExampleReturnValue of this stack to "cancel"
end mouseUp
...etc...
See our web site: http://www.xworlds.com/metacard/
for articles and information on learning to use MetaCard.
Hope this helps!
Regards,
Kevin
> Regards, Guy
Kevin Miller <[EMAIL PROTECTED]> <http://www.xworlds.com/>
Cross Worlds Computing, MetaCard Distributors, Custom Development.
Tel: +44 (0)131 672 2909. Fax: +44 (0)1639 830 707.