Open/Close DC Options Dialog

I dabble in ruby and the SketchUp API…

I’ve been able to produce some code so that I can toggle between layer states using a shortcut key and following my success wanted to be able to toggle the DC Options dialog to open and close.

I looked at @DanRathbun’s code in this post and wrote this…

require 'sketchup.rb'

DC ||= $dc_observers.get_latest_class

def toggle_DC
		
	if (DC.configure_dialog_is_visible())
		DC.close_configure_dialog()
	else
		DC.show_configure_dialog()
	end
		
end

if( not file_loaded?("toggleDC.rb") )
    
    add_separator_to_menu("Tools")
    
    UI.menu("Tools").add_item("Toggle DC Dialog") { toggle_DC }

end

file_loaded("toggleDC.rb")

If I select a DC, when I click the menu item the DC Options dialog opens, but when I click the menu item a second time the dialog doesn’t close. I have to re-select the DC then click the menu item for the dialog to close.

Any pointers to what I need to do to make it work without re-selecting the DC…?

Just realised that I don’t need any code, that I can assign a shortcut to window>component options but I encounter the same behaviour…

Select the component, go to window>component options which opens the options dialog, but you have to click the component again to close the dialog box with window>component options

EDIT: of course it’s not that you have to click on the component, it’s that the components option dialog has focus and clicking anywhere on the main SketchUp window gives back focus.

All for the sake of avoiding a mouseclick, I’ve created an AHK hotkey to click the main SketchUp window and then perform window>component options

I don’t understand. I don’t have a problem with either the menu item or the toolbar button closing the window. And it doesn’t matter whether a DC instance is selected or not.


BTW, on MS Windows platform, ALT+F4 is a global shortcut to close any window that has focus.

In my quest to reduce mouse clicks, awkward and two hand keypress combinations and improve my productivity, I wanted to open and close the Component Options dialog with a single keyboard toggle shortcut.

With the DC selected pressing the keyboard shortcut will open the dialog. You make your choices in the dialog and click apply.

At this point the dialog still has focus and pressing the keyboard shortcut does not close the dialog.

Only when you bring focus back to the main SketchUp window will the keyboard shortcut work.

Sure once apply in the dialog has been clicked one can do alt+F4

Ah okay I understand. Well, the main issue is that extensions devs may not want application shortcuts to remove focus from their web dialogs. (I believe there may already be some topic threads on this.)

It might be nice if a dialog author could decide and give their dialog instance a boolean shortcuts: true attribute.