How to hide or dock HtmlDialog? Is c extension only the solution?

The #bring_to_front method is used to bring the window to the front, putting it on top of other windows even if its minimized. :wink:
(however #minimize would be nice too…)

I just worked up this hack using a singleton method defined upon the object …

WIN ||= Sketchup.platform == :platform_win
require 'win32ole' if WIN

def @dialog.minimize
  # Make sure that this dialog is the active window:
  self.bring_to_front
  if WIN
    win = WIN32OLE.new("WScript.Shell")
    win.SendKeys("% ") # ALT+SPACE Activates the upper left window menu
    win.SendKeys("n")  # Choose the miNimize item from the menu
  else # Mac
    # Does this work for Mac child windows (or only the SketchUp window)?
    Sketchup.send_action('performMiniaturize:')
    # ... otherwise send a Command M with cliclick utility
  end
end

ADD: This is a “hack” because it is likely that the hotkey for minimize in the window menu is localized when the Windows system language is other than Windows.

1 Like

On Windows, like on Mac, ‘Hide’ means ‘hide’, not minimize (which you can do from the button in the titlebar). The Win API has also different methods and constants to hide versus minimize.

Hiding a dialog is convenient because it keeps its environment unchanged, Javascript, visual elements, etc…

Showing it again after Hide is much faster than to recreate the dialog, since you do not have to go through the loading sequence of html, javascript and reset the interactive context to what it was when the dialog was closed.

Yes, yes, I know, … I meant from the user’s point of view.

And BTW … if the developer uses the UI::HtmlDialog::STYLE_UTILITY there is no minimize button on it’s caption bar, nor is there an upper left window menu, so my “hack” does not work to minimize the window. Utility style windows are meant to be tool inspector child windows which normally do not minimize. (So developers can purposefully prevent users from minimizing such windows.)

I will agree … even though minimizing has the same benefits. There can be situations where the developer does not wish to have his dialog minimize to a tile on the taskbar. (And as mentioned above, tool utility windows are not supposed to be minimized to the taskbar, so they would need to be hidden instead.)

Again, I agree.

Please open request issues for minimize and hide methods for the UI::HtmlDialog class.

:+1: