Custom Select Tool That Displays Tag Name

No, they only control the document inside the window.

You can use the new Sketchup::focus method to give the main window the focus after the dialog is displayed and it’s document has been fully rendered.

In the dialogs’ JavaScript …

      function ready_handler() {
          if (document.readyState === 'complete') {
              sketchup.ready() ;
              // Detach listener:
              document.removeEventListener('readystatechange', ready_handler) ;
          }
      }

      document.addEventListener('readystatechange', ready_handler) ;

And then your Ruby dialog object needs a callback named “ready” …

    @dlg.add_action_callback("ready") { |dialog, params|
      puts "DIALOG CONTENT LOADED" if $VERBOSE
      Sketchup::focus if Sketchup.respond_to?(:focus)
    }

There is also an old dummy dialog “hack” that only works on Windows.
(You open a tiny temp dialog and close it with a timer, and the main application gets the focus.)
How to set Focus to Mainwindow - #14 by indie3d

There is also a WIN32OLE command. See …
How to set Focus to Mainwindow - #6 by DanRathbun

1 Like