Center Webdialog over Sketchup window
-
Hi,
I need my WebDialog to be centered over SketchUp window each time it is opened.
I've tried to find similar posts, without success (I found how to center over screen
http://www.sketchucation.com/forums/scf/viewtopic.php?f=26%26amp;t=6067, but not how to center over Sketchup window). Are there some functions in Ruby API for that or should use some Windows API functions?So my question is how to get position and size of Sketchup application window?
Once I have that info I can easily do WebDialog positioning.Marija.
-
The methods
Sketchup.active_model.active_view.vpwidth
and.vpheight
give you the dims of the current pane in pixels.
As you say... half those to get the center.
Deduct from those half the web-dialog's width or its height to get the top left corner location, to move the webdialog to, using http://www.sketchup.com/intl/en/developer/docs/ourdoc/webdialog#set_position
BUT if the SKP window is not maximized then you could have problems ?
You then need to use WIN/MAC system calls to find the location of the SKP's window itself... -
Hi TIG,
I know about active_view, but problem is if dialog is not maximized and if/when it is moved from screen center.
Definitely Windows system calls are needed. I'm now experimenting on that and I hope to find some solution soon.Thanks
-
You could theoretically read the screen dimensions using JavaScript, divide by two and subtract half of the dialog's width and height (you can read the inner width without window border using JavaScript).
This is not recommended. If it is not essential to the functioning of you plugin, think again if you can get along without it. This causes your dialog to launch initially with different dimensions and then "jump". On a multi-monitor setup, you don't know whether the dialog is on the second monitor, and the above formula will give you coordinates for the first monitor. The dialog will jump to the first monitor, if it was launched (by registry preferences) on the second one.
Advertisement