sketchucation logo sketchucation
    • Login
    🤑 SketchPlus 1.3 | 44 Tools for $15 until June 20th Buy Now

    Accessing Menu Objects from Submenu's

    Scheduled Pinned Locked Moved Developers' Forum
    4 Posts 2 Posters 274 Views
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • D Offline
      david.
      last edited by

      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.

      1 Reply Last reply Reply Quote 0
      • Dan RathbunD Offline
        Dan Rathbun
        last edited by

        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')

        I'm not here much anymore.

        1 Reply Last reply Reply Quote 0
        • D Offline
          david.
          last edited by

          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.

          1 Reply Last reply Reply Quote 0
          • Dan RathbunD Offline
            Dan Rathbun
            last edited by

            @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 with Enumerable methods (which should include each_item and each_submenu iterator methods;) nor any name, parent, etc getter methods.

            We'll have to cross our fingers for the next MR.

            I'm not here much anymore.

            1 Reply Last reply Reply Quote 0
            • 1 / 1
            • First post
              Last post
            Buy SketchPlus
            Buy SUbD
            Buy WrapR
            Buy eBook
            Buy Modelur
            Buy Vertex Tools
            Buy SketchCuisine
            Buy FormFonts

            Advertisement