Skip to content
Aerilius edited this page Apr 18, 2013 · 6 revisions

Sizing Window

Minimum and maximum Size

webdialog.min_width / min_height / max_width / max_height limits the size of the WebDialog which the user can set. However it doesn't limit resizing via the API.

Behaviour under Windows

Under Windows the minimum and maximum size limits the outer window size - including window frame.

Behaviour under OSX

Under OSX the minimum and maximum size limits the client size - excluding window frame.

WebDialog.set_size

Sets the outer size of the dialog, not the content (client size), so we might need to consider the width of window decorations (border, titlebar). The size of window decorations can differ depending on the installed window theme, font and dpi settings, so it is good to avoid any assumptions if the exact size is important for you.

As a side effect, this method brings the dialog to the front and it potentially gets focus (important to consider if several dialogs/tool windows are open, or if you have onfocus JavaScript event handlers).

When the dialog is already shown, the resizing direction is on Windows towards bottom right and keeps the dialog's top left corner fixed. On OS X, the dialog's bottom left corner is fixed and is resized towards top right. Because of that, use first set_size and only after that set_position. If you wanted to change only the size but preserve the position, you can measure the dialog's current position in JavaScript (window.screenX||window.screenLeft, window.screenY||window.screenTop), send it to Ruby and set that position again after resizing.

Calling set_size and set_position consecutively does not guarantee that they happen simultaneously, you might notice some flickering with an in-between step.

Manual resizing as well as script-induced resizing triggers the onresize JavaScript event. In Internet Explorer it is triggered twice.