Accessing Menu Objects from Submenu's
-
Is there any way to access a submenu's? I know I can access top level menu's via UI.menu( ... ). I've searched, but it appears there is no interface to access submenu's that I've added under the top level.
-
Sure there is, IF you are the one creating them.
Just save a reference to the submenu instance. A module var works well. Constants can also work:
PluginsTopMenu = UI.menu('plugins') PluginsSubMenuExporters = PluginsTopMenu.add_submenu('Exporters')
-
Yes, I realized that. I thought there might be a way through the SU UI similar to accessing toolbars that have been created. Apparently, not. Not a big issue.
-
@david. said:
Yes, I realized that. I thought there might be a way through the SU UI similar to accessing toolbars that have been created. Apparently, not. Not a big issue.
Actually the API lacks a Toolbars collection, which we have wanted. Now with the name method (just added, we can create one, 'on the fly'.)
module SuchandSuch Toolbars={} ObjectSpace.each_object(UI;;Toolbar) {|tb| Toolbars[tb.name]=tb } end
You refer to the just added method
each
which accesses the buttons (UI::Command
objects,) on a given toolbar.But ... the
Sketchup::Menu
class has not yet been updated withEnumerable
methods (which should includeeach_item
andeach_submenu
iterator methods;) nor anyname
,parent
, etc getter methods.We'll have to cross our fingers for the next MR.
Advertisement