sketchucation logo sketchucation
    • Login
    ℹ️ Licensed Extensions | FredoBatch, ElevationProfile, FredoSketch, LayOps, MatSim and Pic2Shape will require license from Sept 1st More Info

    How can I use "createPopupMenu" to create a right click Menu

    Scheduled Pinned Locked Moved Developers' Forum
    6 Posts 3 Posters 6.1k Views 3 Watching
    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.
    • S Offline
      season_x
      last edited by Gábor

      first,I already get sketchup handle "hMainwnd",then I want to create a right-click menu:

      #---------
      def AddPopupMenu(hMainwnd,x,y)
      createPopupMenu = Win32API.new('user32.dll', 'CreatePopupMenu','', 'l')
      appendMenu = Win32API.new('user32.dll', 'AppendMenu','liip', 'b')
      clientToScreen = Win32API.new('user32.dll', 'ClientToScreen','lp', 'b')
      trackPopupMenu = Win32API.new('user32.dll', 'TrackPopupMenu','liiiilp', 'b')

          # point = [0,0]
          hMenu = createPopupMenu.call
          appendMenu.call(hMenu,0x00000000,200,"Move")
          #clientToScreen.call(hMainwnd,point)
          trackPopupMenu.call(hMenu,2,x,y,0,hMainwnd,nil)
      

      end
      def onRButtonUp(flags, x, y, view)
      hMwnd = GetSketchupWmd()
      AddPopupMenu(hMwnd,x,y)
      end
      #--------------------------
      but,when I right_click,Nothing happened on my sketchup!I don't know if this method is right or wrong.

      1 Reply Last reply Reply Quote 0
      • S Offline
        season_x
        last edited by

        another way, I want to create a new context menu and Make it appear with sketchup context_menu at the same time .I already tried "getmenu" function,but it's just sketchup context_menu.
        anybody know ?

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

          @season_x said:

          ... I want to create a right-click menu:

          What do you want to create a context menu for ?
          (There needs to be a context ... ie, something selected, or nothing selected, or a certain tool is active, etc.)

          Then you will wish to insert menu items onto the context menu. What kind of command(s) ?

          SketchUp's Ruby API already has this feature available, so you need to work WITH the API as it exposes SketchUp's native context menu handler.

          You cannot just brute force try to stomp over the native handler!

          * UI::add_context_menu_handler class method

          • UI::Command class

          I'm not here much anymore.

          1 Reply Last reply Reply Quote 0
          • S Offline
            season_x
            last edited by

            If I add common tools to the menu, They will make it too long,So I wanted to create a side-by-side menu ,so it wouldn't look too long.You know there are a lot of common tools,Their keyboard shortcuts were hard to remember,Many good software programs have a rich right - click menu,Clearly separated, not mixed.I believe that sketchup in the future will incorporate full screen capabilities,I'm a programmer and a designer, and I want to bulid model quickly,I think Right - click menus are more important than toolbars and shortcut key.Those are my reasons.Customizing personalized functional menus is also convenient and fun, isn't it? ☀

            1 Reply Last reply Reply Quote 0
            • TIGT Offline
              TIG Moderator
              last edited by

              You can use the API to add submenus to the context-menu,
              Then each related set of entries only occupy one submenu item.
              You can even nest even submenus...

              Also because it is a context-menu you can set up its items to only be shown in the list if a certain context applies - e.g. only if the selection contains faces offer some face related tools, or if the selection is just one section-plane then offer some special section-plane related tools...

              TIG

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

                @season_x said:

                I think Right - click menus are more important than toolbars and shortcut key.

                Doug Olivier (formerly a Trimble employee) is working on a popup button matrix called GhostMenu:

                There is a beta version available to test. https://app.ghost.menu/

                It uses a keyboard shortcut to popup the GhostMenu.

                (But I cobbled up a little script to insert a command for GhostMenu into the top of SketchUp's context menu.)

                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