Jump to content
Claris Engage 2025 - March 25-26 Austin Texas ×

This topic is 3798 days old. Please don't post here. Open a new topic instead.

Recommended Posts

Posted

I plan to make extensive use of modal windows in my application.  When opening a modal window, I want generally to center it over its parent window.  I do that by calculating relative window sizes and positions and then using Move/Resize Window to get it to be the proper shape and size.

 

However, I have a "window flicker" problem--when I first create the window and assign the layout, the window is the same size as the underlying window.  I cannot compute the position of the window until after I do a Resize to Fit so that I know the size of the new window.  But by then the window is visible, so moving it results in it flickering from its created position in the upper left corner to its desired position.

 

I'd like everything to be hidden/invisible until I've calculated the windows desired position.  How can I do that?

 

My script sequence is:

  New Window

  Go to Layout

  Adjust Window - resize to fit (to make window fit the layout)

  Move/Resize window to desired size and position, using dimensions made available by adjusting window to fit the layout

 

Running FMP 13 Advanced on Windows 7 but will deploy to Mac.

 

Thanks!

Posted (edited)

Hi Seeker4!  Welcome to FMForums!!

 

Here is one way FILE ATTACHED.  It means splitting the process into two.  The theory is this:  You know the size of the layout which will be modal so you can use OnLayoutEnter and script parameter to tell any incoming script that layout's size so you don't need Adjust Window at all; it can all be handled by Move/Resize Window[].  Attached is an example but it would look like this:

 

Your regular script fired from your parent layout:

# Collect the center of the parent window so you can centre modal later
Set Variable [ $$centerHeight; Value:Get ( WindowTop ) + Get ( WindowHeight ) / 2 ]
Set Variable [ $$centerWidth; Value:Get ( WindowLeft ) + Get ( WindowWidth ) / 2 ]
#
New Window [ Top: -3000; Left: -3000; Style: Document] <-- make it *dialog instead of course
Freeze Window
Go to Layout [ “ModalWindow” (ModalWindow) ]

OnLayoutEnter script trigger:

# Enter the script parameter on each modal window which tells the Height/Width
# For this example I as lazy and used: "400 400"
Set Variable [ $sp; Value: Get ( ScriptParameter ) ]
Set Variable [ $height; Value:LeftWords ( $sp ; 1 ) ]
Set Variable [ $width; Value:RightWords ( $sp ; 1 ) ]
#
Move/Resize Window [ Current Window; 
Height: $height; 
Width: $width; 
Top: $$centerHeight - $height / 2; 
Left: $$centerWidth - $width / 2 ]
#

You could also just pass the parent layout's sizes as parameter but it is very late for me and my eyes keep crossing.   And no flash at least on Mac.  The idea is that this same script can be used for all your modal windows and you just specify their size within their script parameter.

 

:-)

 

ADDED:  * be sure when you make the window Dialog (modal) that you leave a way out - a button to close the window

 

Make small change

ModalWindow.fmp12.zip

Edited by LaRetta
Posted

Thank you.  I had not thought of using a script trigger, and that clearly is very helpful in this case.

 

I had hoped not to specify the desired size of the layout window beforehand but instead allow the window to size automatically to the layout.

Posted

Yes I understand but as you recognise, Adjust Window (resize to fit) produces the effect you wish to avoid.  The only way that I can tell to avoid that is to set the window size.  Another option is to use a table to hold the layouts and their sizes but that will mean specifying the layout name (or layout ID).  By using the script parameter on the layout's trigger itself, you keep the specs tied to the layout - much less overhead.

 

But maybe others can provide alternate for you; I could not find any other way.

Posted

You could do the "adjust" while the window is hidden I guess.

 

A nice on-step method of spawning a new window and setting its size is the Go To Related record script step.  If no relationship exists, just use the TO where you are coming from and do an change layout immediately after

Posted

You could do the "adjust" while the window is hidden I guess.

 

But with my testing, that brings the window to the front into view.  But I will certainly play with your other suggestion, Wim!  Thank you!

Posted

I've been experimenting with using OnLayoutEnter and specifying the window dimensions as you suggested.  However, the dimensions I have available in the layout inspector are the content dimensions, rather than the window dimensions, which can vary depending on whether tool and formatting bars are visible, and I presume vary with the platform as well.  I'll try computing the difference between window and content dimensions at startup and applying those to the modal window.

This topic is 3798 days old. Please don't post here. Open a new topic instead.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.