WebDialog centered on screen or SU main window

How can I, if possible to center the dialog on the screen or center of main SU window ?
Thanks
PS: Bonus, can a WebDialog be made modal ?

UI::WebDialog is now deprecated.

Going forward, please use the Chromium-based UI::HTMLDialog for SketchUp 2017+.


You cannot access the total height of the application window (in realtime) but you can get close:

model = Sketchup.active_model
view = model.active_view
height = view.vpheight
width = view.vpwidth
@top = ((height - @dlg_height)/2).to_i
@left = ((width - @dlg_width)/2).to_i

Then use @top and @left as the screen coordinates for your dialog.

The view calls do not take into account the space used by menus, statusbar and toolbars.

1 Like