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

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

Postby season_x » Thu Aug 06, 2020 3:53 pm

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.
0

season_x 
 

Re: How can I use "createPopupMenu" to create a right click

Postby season_x » Sat Aug 08, 2020 3:18 pm

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 ?
0

season_x 
 

Re: How can I use "createPopupMenu" to create a right click

Postby Dan Rathbun » Thu Aug 13, 2020 11:06 pm

season_x wrote:... 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!

0
    I'm not here much anymore. But a PM will fire email notifications.
    User avatar
    Dan Rathbun 
    PluginStore Author
    PluginStore Author
     

    Re: How can I use "createPopupMenu" to create a right click

    Postby season_x » Fri Aug 14, 2020 2:08 pm

    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? :enlight:
    0

    season_x 
     

    Re: How can I use "createPopupMenu" to create a right click

    Postby TIG » Fri Aug 14, 2020 2:35 pm

    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...
    1
    TIG
    User avatar
    TIG 
    Global Moderator
     

    Re: How can I use "createPopupMenu" to create a right click

    Postby Dan Rathbun » Fri Sep 11, 2020 4:15 pm

    season_x wrote: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.)
    0
      I'm not here much anymore. But a PM will fire email notifications.
      User avatar
      Dan Rathbun 
      PluginStore Author
      PluginStore Author
       

      SketchUcation One-Liner Adverts

      by Ad Machine » 5 minutes ago



      Ad Machine 
      Robot
       



       

      Return to Developers' Forum

      Who is online

      Users browsing this forum: martucja, taufiqis13 and 10 guests

      Visit our sponsors: