Skip to content
Thomas Thomassen edited this page May 27, 2013 · 4 revisions

You can specify the arguments as either a comma separated list, or as a single Hash object. Currently the manual is missing information for both of these.

Comma Separated Arguments

  • dialog_title - The title to be displayed in the webdialog.
  • scrollable - true if you want to allow scrollbars, false if you do not want to allow scrollbars.
  • pref_key - The registry entry where the location and size of the dialog will be saved. If preferences_key is not included, the location and size will not be stored.
  • width - The width of the webdialog.
  • height - The height of the webdialog.
  • left - The number of pixels from the left.
  • top - The number of pixels from the top.
  • resizable - true if you want to allow the window to be resize by the user.

Hash argument

options = {
    :dialog_title => title,
    :scrollable => false,
    :preferences_key => 'MyDialog',
    :height => 300,
    :width => 400,
    :left => 200,
    :top => 200,
    :resizable => true,
    :mac_only_use_nswindow => true
}
@dialog = UI::WebDialog.new(options)

But the hash exposes a new undocumented argument, :mac_only_use_nswindow. No further info has been given about this argument.

Remembering position and size

Every time the WebDialog is moved and sized the settings is written. However, these settings are only read when UI::WebDialog.new is called. webdialog.show will display the window using the position and size of when the WebDialog was created. Because of this one has to destroy and recreate the WebDialog object everytime before calling webdialog.show if one want to remember last settings.

Fixed window size

When you specify position and size Sketchup only uses those values the first time you create the dialog. After that it reads the last used values from the registry. That might be want to you want for resizable windows. But maybe not for windows with a fixed size which the user can't resize.

When you develop a plugin you might find that you need to change the size of your fixed size window, but you can't see the effect because Sketchup just reads your last values. In which case you need to delete the registry settings for your Webdialog, or use the .set_size method after you create the fixed size window to ensure the correct size.

Scrollbars

The scrollbar argument does not seem to work on PC. In order to disable the scrollbars you must set a CSS property. What HTML to assign this property to depends if your HTML uses Quirks Mode or Standards Mode.

If you're using Quicks Mode you assign it to the BODY element:

body { overflow: hidden; }

If you are using Standard Mode you assign it to the HTML element:

html { overflow: hidden; }

This is because the effective root element in an HTML document differs from Quicks to Standards Mode.

And if you do not specify a preference key, Sketchup seem to disregard both size and position.