Use_content_size : true, swaps the max_height and max_width (HtmlDialog)

If you set the use_content_size to true, this will limits the maximum width of the UI::Html dialog.
(SU 21.1.299 Windows)
Do you experience this too?
Is that intentional?

Code
dialog = UI::HtmlDialog.new(
  dialog_title: "Dialog Example",
  preferences_key: "my_name_my_extension_my_dialog",
  use_content_size: true,
  scrollable: true,
  resizable: true,
  width: 600,
  height: 400,
  left: 100,
  top: 100,
  min_width: 50,
  min_height: 50,
  max_height: 1000,
  style: UI::HtmlDialog::STYLE_DIALOG
)
dialog.set_url("https://www.sketchup.com")
dialog.show

html_bug

This is likely not intentional. It is was probably thought that :max_width would be set by the coder. It has a default of -1 according to the documentation.

Wait!
For sure it should be not intentional. I figured out now the real bug:
If you set the use_content_size to true, the max_height and max_width values are swapped!
(In my first post the max_height:1000 was taken as a max_width:1000 )

use_content_size: true,
dialog = UI::HtmlDialog.new(
  dialog_title: "Dialog Example",
  preferences_key: "my_name_my_extension_my_dialog",
  use_content_size: true,
  scrollable: true,
  resizable: true,
  width: 200,
  height: 200,
  left: 100,
  top: 100,
  min_width: 50,
  min_height: 50,
  max_height: 300,
  max_width: 500,
  style: UI::HtmlDialog::STYLE_DIALOG
)
dialog.set_url("https://www.sketchup.com")
dialog.show

use_true

use_content_size: false,
dialog = UI::HtmlDialog.new(
  dialog_title: "Dialog Example",
  preferences_key: "my_name_my_extension_my_dialog",
  use_content_size: false,
  scrollable: true,
  resizable: true,
  width: 200,
  height: 200,
  left: 100,
  top: 100,
  min_width: 50,
  min_height: 50,
  max_height: 300,
  max_width: 500,
  style: UI::HtmlDialog::STYLE_DIALOG
)
dialog.set_url("https://www.sketchup.com")
dialog.show

use_false

1 Like

Oh good catch !

:clap:

A workaround is to use the new set_content_size method rather than constructor arguments.


Also, some quick testing shows that the documentation lacks to inform us that the use_content_size flag also affects the positioning.

If you do not specify top or left (or you set them to 0,) the window is positioned relative to the top left of the content area (not the upper left corner of the window frame,) and so will put the caption bar and left frame border offscreen.

This can make it difficult for users to know how to close the dialog unless it provides a close button in the content. (Windows has a built-in ALT+F4 shortcut to close the active window. Don’t know what Mac has.)

2 Likes

Command-W

1 Like

Yes, the intention of the developers was probably that we use the “novelties” together… But they did not describe it properly and made some mistakes with relation to “old” methods.