Empty HtmlDialog on Windows

I’ve been playing with the UI::HtmlDialog class to create a simple interface that allows the user to input some information and it works just great on the Mac. Under my plugin directory I have a folder called html in which I keep two files referenced in my Ruby code. That is, I use the following structure:

SketchUp / Plugins / root_rb
SketchUp / Plugins / plugin_dir / main_rb
SketchUp / Plugins / plugin_dir / html / a.html
SketchUp / Plugins / plugin_dir / html / b.html 

However, when testing my extension on Windows (under both SU 2021 and SU 2022), the UI that was present on the Mac doesn’t show up anymore. (I should also mention that this is Windows running on Bootcamp.) All I get is an empty pop-up and when I right-click to view the page source I only see the following:

<html><head></head><body></body></html>

In addition, navigating to the Sources tab under DevTools reveals that both a.html and b.html have the following content (please side scroll to see everything):

        if (document && document.body && document.body.style) {          document.body.style.overflow="hidden";        }

This is clearly not right, even though the absolute paths to the HTML files are consistent with what I have on the filesystem.

On the Ruby side of things I am using the canonical way to load the HTML, i.e.

dialog.set_file(File.join(__dir__, 'html', 'a.html'))

When I try to read the file the file via

File.read(File.join(__dir__, 'html', 'a.html'))

I get the following error in the Ruby console (note that I condensed the absolute path):

Error: #<Errno::ENOENT: No such file or directory @ rb_sysopen - C:/Users/.../html/a.html>

I even tried to run SketchUp as an administrator and that didn’t help either. I am really stuck at this point and have no other ideas.

Any help is greatly appreciated! Thank-you!

This is quite incredible… I can read the file like this:

File.read(File.join(__dir__, 'html', 'a.html.txt'))

Note that I manually created the HTML files by right-clicking and selecting Text Document. It seems that this adds the .txt extension after .html, which then screws up the UI::HtmlDialog.set_file method…

I have no words… :no_mouth:

FYI :wink:
How to Save a File with Notepad Without the TXT Extension (thesitewizard.com)

1 Like

Thanks for sharing that link.

I’m still furious at how Windows manages to waste my time each and every time I’m doing something with it. Nothing works as you would expect: from the extremely convoluted Office apps to renaming files on your computer. It just seems that they created an operating system to frustrate people, not help them do their job…

:grinning:
Another point of view:

I’m still furious at how Mac - iOS manages to waste my time each and every time I’m doing something with it. Nothing works as you would expect: from the extremely convoluted xx apps to locating files on your computer. It just seems that they created an operating system to frustrate people, not help them do their job…
-:stuck_out_tongue_winking_eye:

:peace_symbol: :beer:

Haha, to each their own I guess. On the Mac everything is so easily accessible. I can navigate the filesystem from the root and have a nice tree-like structure in front of my eyes. On Windows I don’t even have a File Explorer icon – I always need to remember how this app is called and look it up.

Anyway, I’m glad that this thing is working after all. The only gripe I have is that the width and height of the HtmlDialog are not quite consistent between macOS and Windows. What was 200x100 on the Mac has to be changed to 300x120 on Windows for the content to fit within my pop-up. Is there any way to make these dimensions consistent between the operating systems or do I just have to hardcode the numbers depending on the OS?

Sure, both OS have it own drawbacks and benefits. Also depends on the user “taste”, and what the user used to…

For "consistent HTML window sizes:
(Generally I find out most of the web pages looks a little different on both OS-es, so no surprises about HTMLdialog.)
You may need to include the same font, you may need to write a JavaScript call-back to check the content size and resize the dialog accordingly…
Or as I usually do, take a more or less compromised size, then leave the user to resize it as she/he like. Next time the dialog will remember to that size.

2 Likes

If you instead slow down and observe the way that Windows features work, you’ll adapt to how they work, instead of how you think they should work.

This is frustration talking. We all know this is not true. Billions of Windows users (incl. myself) have no problems navigating or creating, naming or copying files.

There are however, fundamental Windows OS protocols for doing things that require modifier key + mouse clicks in order to speed file manipulations, make selection sets, or use dialog controls, etc.

Back around the XP days Windows used to come with a video tutorial that explained these “nuggets” of fundamental use. It was removed and I don’t know if it’s now web-based. Anyway, I could never get my elder family members to actually watch the video, even though there was a obvious link to it right on the Start Menu. They would always instead ask me how to do the simplest tasks. (Still do.)

When you right-click in File Explorer and choose New > Text Document
… the empty file is created as "New Document.txt" and then it’s name (minus the file extension) is selected in edit mode. If you ignore this, then start typing "a.html" and press ENTER, then of course the file will retain the .txt extension.

How often do I create .txt files this way? Very seldom, but I do use this feature very often to create empty .rb files. To do this follow this routine:

  • Right-click in File Explorer and choose New > Text Document
  • To select ALL of the filename including the extension, hold SHIFT then click the END key
  • Type the complete new filename and file extension
  • Press ENTER to accept if you’ve typed it correctly (This means actually look at the name in the file listing and correct it if any typo snuck in there.)
  • Press ENTER again to accept the Yes button in the Rename confirmation messagebox.

Easy Peasey.

This is strange as I have a File Explorer icon pinned onto my taskbar. Looks like a file folder.
Right-click it and it’s Jump List opens. (A Windows Jump List is a context menu for taskbar icons that is separated into categorical sections.)

In addition, you should have a user shortcut icon on the Desktop that leads to the user HOME folder. (Called %USERPROFILE% or %HOMEDRIVE%/%HOMEPATH% on Windows.)

Also you should have a This PC shortcut icon on the Desktop that when double-clicked leads to the machine root, showing links to the user’s special folders (Documents, Videos, Music, Downloads, etc.) and the Devices and Drives.

Regarding “nice tree structure” this is also a feature of the Windows File Explorer, but can be switched off. In Explorer see the View > Navigation pane submenu. (But it does not “out of the box” show the entire folder tree, only the level that you are at.)

2 Likes

Thanks for the super detailed post, Dan! I’m not really fond of the Windows way of doing things because many simple tasks require way too many steps. That said, I will try to remember some of these quirks going forward, especially the file renaming procedure.

PS. I feel like I had every right to be frustrated given that I spent 5 hours debugging this and searching the Internet like crazy. (I even tried some of your past suggestions regarding the HtmlDialog, but they didn’t help as I was doing something fundamentally wrong in the first place.)