How to center a new window

Dear All,

I also got another little problem. :frowning:
It’s that I want to open a window and place it at the center of the screen when user clicks the menu.
Let’s say I want to open a window named Sample. I tried it like that
So I place the following code for that menu in the menu editor.
fpmi.nav.openWindow(“Sample”)
fpmi.nav.centerWindow(“Sample”)
But When I test it, It doesn’t show at the center. And another problem is that I have to click the menu twice to show that window in center. I want it to show at the center of the screen at the first time user click the menu. I hope someone help me.

The fpmi.nav.centerWindow function will center a window over a main window. This requires that another window is opened and maximized. You are also probably using the mouseClicked event, so if you change that to the mousePressed or mouseReleased you won’t have to click twice.