how to place a dialog window
sanke at hrz.uni-kassel.de
Fri Nov 10 11:45:34 CST 2006
On Tue Nov 7; Mark Swindell mdswindell at cruzio.com wrote:
> What is the correct syntax to tell Rev where to place a dialog window?
> Ask "What's your name?" (at the location of this wd)
and on Wed Nov 8, Phil Davis revdev at pdslabs.net answered:
> Hi Mark,
> Personally I'm not aware that you can set the screen position of a
> standard Rev
> dialog, though I'm willing to be corrected.
> I often use a substack as a dialog. (snip)
Although I frequently build my own custom dialogs, I also make use of
the possibility to "place" "answer and "ask" dialogs.
This has been implemented in the alternative Metacard IDE since about a
year. The same approach can be used within Revolution if you make the
necessary small changes - only two added lines - to the scripts of the
I have uploaded a sample stack that shows a number of different ways to
place dialogs and how to modify the scripts of the 2.7.x Rev dialogs to
This stack contains modified answer and ask dialogs as substacks. A
folder "modifieddialogs" in the zip-file contains modified versions of
stacks "revanswerdialog.rev" and "revaskdialog.rev" that can be used to
replace the default Rev stacks in folder "toolset" .
An older stack that can be used with Rev 2.6.x can be found on page
"Tools and Samples for Development" at
(Scroll far down on that page).
From the text of the new sample stack:
Normally, an answer dialog or ask dialog is displayed at the center of
the stack from which it called by the "answer" or "ask" command (on
Windows) and on Mac OS slightly above the center of the stack.
The modified card scripts of stack "answer dialog" and "ask dialog"
have two added lines at the end of the preopenstack handler -
immediately before "end preopenstack" - that creates or sets a custom
property "NewLoc" of the dialog.
"if the NewLoc of this stack is not empty then set the loc of this stack
to the NewLoc of this stack
set the NewLoc of this stack to empty"
Line 2 of the above script ensures that the default behavior of the
dialog is restored for the next time you open the dialog and have *not*
specified a "NewLoc" before, meaning the two added lines do not affect
the "normal" behavior of the dialogs unless you choose to determine a
You have to set a value for NewLoc in the script of the calling button
above the line with the "answer" or "ask" command, like
set the NewLoc of stack "Answer dialog" to 150,150
answer "Does this work?"
As "answer dialog" and "ask dialog" are stacks (even as substacks) the
coordinates you set are screen coordinates.
If you want to place the dialogs relative to the stack - e.g. near one
button, to the right of a field etc. - you have to use the globalloc()
property which transforms stack to screen coordinates; example:
To place a dialog below a button you could use:
"put the loc of me into tloc # the position of the calling button
add 90 to item 2 of tloc # the y value
set the NewLoc of stack "answer dialog" to globalloc(tloc)
answer "immediately below the button?""
If you set the x,y values directly instead of a variable you have to
put the values between quotes like
set the NewLoc of stack "answer dialog" to globalloc("150,300")
Compare the different ways to set values for NewLoc in scripts of the
I have added a modified "answer dialog" and "ask dialog" as substacks to
this sample stack. These substacks take precedence over IDE stacks when
you use the "answer" or "ask" command.-
Now, how to change the script of stack "Answer dialog" (likewise for the
"ask dialog") in Revolution
Up to version Rev 2.6.x the answer and ask dialogs were substacks of the
"home" ("license") stack.
From version 2.7.x on the stacks were renamed to "revanswerdialog.rev"
and "revaskdialog.rev" and transferred to folder "toolset".
- choose "open stack" from menu button "File" and open stack
"revanswerdialog" in folder "toolset"
- choose "card inspector" and then "edit script"
- add the two scriptlines just before "end preopenstack"
- save stack "revanswerdialog"
In versions Rev 2.6.x this is different, because answer and ask dialogs
are substacks of stack "Home" (stack "licence.rev")
- check "Revolution UI elements in Lists" under menu button "View"
- open the "Application Browser" and click on "Answer dialog"
- right-click on card ID 1002 to bring up the script editor
- add the two lines
- save the dialog
In both versions 2.6.X and 2.7.x you can also use the message box to
change the script and type
edit script of cd 1 of stack "answer dialog"
(Be sure to "save stack "answerdialog"" in the message box afterwards.)
This is possible although in 2.7.x the answer dialog has been renamed to
"revanswerdialog". This new name is only "the effective filename", the
real name with which the dialog is called is still "answer dialog".
"revanswerdialog" can be used with "open stack" etc. only from the
"File" menu item, not from msg.
Another possibility is to substitute "revanswerdialog" and
"revaskdialog" in folder "toolset" with the two dialog stacks of the
same name in folder "modified dialogs" that comes with this sample stack.
I recommend first to rename the default Rev dialogs to something like
"obs-revanswerdialog" ("obs" for "obsolete").
The new dialogs in folder "modified dialogs" have also the additional
advantage of a much smaller width.
The original Rev dialogs are much too wide for my taste. The minimum
width for the Rev "answer dialog" is 400 pixels, even if the answer
string contains only four chars like with "O.K." .--
More information about the use-livecode