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 } endYou refer to the just added method
eachwhich accesses the buttons (UI::Commandobjects,) on a given toolbar.But ... the
Sketchup::Menuclass has not yet been updated withEnumerablemethods (which should includeeach_itemandeach_submenuiterator methods;) nor anyname,parent, etc getter methods.We'll have to cross our fingers for the next MR.
Hello! It looks like you're interested in this conversation, but you don't have an account yet.
Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.
With your input, this post could be even better π
Register LoginAdvertisement