WebDialogs show / close - Windows vs Mac

I’ve done virtually all of my plug-in work on Windows. Under Windows, whenever one shows a WD, the html page fires a ‘window load’ or ‘document DOMContentLoaded’ event. Additionally, a ‘window unload’ event fires whenever the WD is closed.

On a Mac, from various forum posts and ThomThom’s guide, it’s my impression that the ‘window load’ and ‘document DOMContentLoaded’ events fire after one sets the html for the WD. So, on a Mac –

  1. Do any DOM events fire when the WD is shown?

  2. If not, can one set DOM properties immediately after the WD is shown, or is it best to do so via the block passed to WD.show?

  3. Do any DOM events fire when the WD is closed?

  4. if not, can one query the DOM (or call WD.execute_script) when the WD.set_on_close block is called?



Just thought of something. If, on a Mac, the DOM fires events after one sets the html for the WD, the implication is that the DOM is accessible regardless of whether the WD is visible or not.

Hence, do callbacks and execute_script work all the time?




if you add a working test file of what you presume won’t work, it’s easier to see if your right, then dig through a zillion examples…

EDIT: and they remain accessible until you close SU…

Yea, the webdialogs act differently depending on the platform. This is due to the different implementations of a web view for the different web engines. Unfortunate and confusing.

For mac I always use show_modal instead of show. Like that:

if Sketchup.platform == :platform_osx

Just saying. =)

1 Like

Just be aware that on Mac, show_modal doesn’t do everything you might expect. It pops the window to the front, but does not lock input to that window the way one expects from a “modal” dialog.

Yes, I use dialog#show_modal just because the window always stay on front. dialog#show on mac doesn’t do that.
In my case I don’t need to lock input too.

Thanks for warning anyway.