Traditionally, the size with which you create a WebDialog included the window borders and titlebar, leading to a smaller HTML area (this is often what developers didn’t want because they design the size of the HTML content and the window borders are unpredictable). To my knowledge, this behavior was not changed with the introduction of HtmlDialog.
→ Is your observation about the size of the window in physical pixels of the HTML content in virtual pixels applied by the browser engine?
You may have an OS-scaling factor other than 1.0 (100%).
→ What operating system and version and SketchUp version do you use?
There was an OS&SU-specific inconsistency between scale factor of window coordinates/size and those inside the HTML, but in the latest combination of SketchUp 2018 and Wine/Windows 10 it is fixed.
I’m using SketchUp Pro 2017 and Windows 10. Perhaps we found one of the reasons here.
Besides, I have observed that the window is keeping the last window size I set. For example, let’s say I set resizable: true in the code, resize the window to 600x400 manually with the mouse and close SketchUp.
Then, I set width: 200, height: 100 and resizable: false in the code and restart SketchUp. When I open the window, it does it at 600x400.
It’s like the dialog has “memory” and does not meet the parameters left, top, width, height. It always opens at the last position and size it was before closing.
To get the dialog to show at the size you have specified in code you can comment out the preferences_key argument and add it back once you have found values you are happy with.
You can also manually delete the position from the preference file (C:\Users<Username>\AppData\Local\SketchUp\SketchUp 2019\SketchUp\PrivatePreferences.json) and restart SketchUp.
You can also try creating it first, and then setting its properties before showing it. When I set center=true inside the new statement, the dialog is not centered. When I create it first and then do
dialog.center = true
dialog.show
It is centered. This might also work for the size properties with set_size?
I’m ashamed to admit that is what I was trying to do. I have just re-read the documentation and now don’t understand why I did that. My best excuse might be a late night at work?