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

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

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

    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 8 Aug 2020, 14:18

      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
      • D Offline
        Dan Rathbun
        last edited by 13 Aug 2020, 22:06

        @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 14 Aug 2020, 13:08

          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
          • T Offline
            TIG Moderator
            last edited by 14 Aug 2020, 13:35

            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
            • D Offline
              Dan Rathbun
              last edited by 11 Sept 2020, 15:15

              @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